News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Advanced SSI FAQ

Started by Tomer, June 24, 2004, 05:47:39 PM

Previous topic - Next topic

[Unknown]

$posts = ssi_recentPosts(25, array(), 'array');
$name = 'MsHoney';

foreach ($posts as $post)
{
echo '
<table border="0" width="100%" align="center">
<tr>
<td><b>', $post['poster']['link'], '</b></td>
</tr>
<tr>
<td>', $post['subject'], '<br /><br /></td>
</tr>
</table>
<br />';

if ($post['poster']['name'] == $name)
echo $row['poster']['link'];
}


Don't use Lamper's ugly formatting it makes it harder :P.

-[Unknown]

Elijah Bliss

Quote from: [Unknown] on July 03, 2004, 12:58:33 AM
$posts = ssi_recentPosts(25, array(), 'array');
$name = 'MsHoney';

foreach ($posts as $post)
{
echo '
<table border="0" width="100%" align="center">
<tr>
<td><b>', $post['poster']['link'], '</b></td>
</tr>
<tr>
<td>', $post['subject'], '<br /><br /></td>
</tr>
</table>
<br />';

if ($post['poster']['name'] == $name)
echo $row['poster']['link'];
}


Don't use Lamper's ugly formatting it makes it harder :P.

-[Unknown]

lol.

thanks for the help, I ran the script but I'm still having problems. Other recent topics from other posters are being displayed. It seems that the $post variable is overriding the $name variable.

What I was trying to do was to display only recent topics by the poster MsHoney.  Is what I'm trying to do even possible?
here's my ssi test link:
http://blaqboard.com/testportal.php

[Unknown]

Try:

echo '<pre>Name: ', $name, '<br />';
print_r($post);
echo ''</pre>;

Inside the loop...

-[Unknown]

Elijah Bliss

Quote from: [Unknown] on July 03, 2004, 01:58:07 AM
Try:

echo '<pre>Name: ', $name, '<br />';
print_r($post);
echo ''</pre>;

Inside the loop...

-[Unknown]

This is what I have so far:
$posts = ssi_recentPosts(8, array(), 'array');
$name = 'MsHoney';



foreach ($posts as $post)
echo '<pre>Name: ', $name, '<br />';
print_r($post);
echo '</pre>';

{


      echo '
               <table border="0" width="100%" align="center">
                     <tr>
                                <td><b>', $post['poster']['link'], '</b></td>
                      </tr>
                        <tr>
                                <td>', $post['subject'], '<br /><br /></td>
                    </tr>
                </table>
                <br />';

       if ($post['poster']['name'] == $name)
             echo $row['poster']['link'];
}


and this is what is displayed:

Name: MsHoney
Name: MsHoney
Name: MsHoney
Name: MsHoney
Name: MsHoney
Name: MsHoney
Name: MsHoney
Name: MsHoney
Array
(
    [board] => Array
        (
            [id] => 2
            [name] => The BlaqBoard Jungle
            [href] => http://www.blaqboard.com/v2/Diesel/Edition/index.php?board=2.0
            [link] => The BlaqBoard Jungle
        )

    [topic] => 21640
    [poster] => Array
        (
            [id] => 97
            [name] => MsHoney
            [href] => http://www.blaqboard.com/v2/Diesel/Edition/index.php?action=profile;u=97
            [link] => MsHoney
        )

    [subject] => Shyne's New Website
    [short_subject] => Shyne's New Website
    [time] => Today at 08:20:48pm
    [timestamp] => 1088824776
    [href] => http://www.blaqboard.com/v2/Diesel/Edition/index.php?topic=21640.msg361538;topicseen#msg361538
    [link] => Shyne's New Website
    [new] => 1
    [newtime] => 0
)


               

MsHoney

Shyne's New Website



http://blaqboard.com/testportal.php

[Unknown]

No, no, like this:

foreach ($posts as $post)
{

echo '<pre>Name: ', $name, '<br />';
print_r($post);
echo '</pre>';


      echo '
               <table border="0" width="100%" align="center">
                     <tr>
                                <td><b>', $post['poster']['link'], '</b></td>
                      </tr>
                        <tr>
                                <td>', $post['subject'], '<br /><br /></td>
                    </tr>
                </table>
                <br />';

       if ($post['poster']['name'] == $name)
             echo $row['poster']['link'];
}


Here's a basic rundown:
Quoteforeach ($posts as $post) <-- look at each post.
{ <-- use everything inside these curly braces to look at them.

echo '<pre>Name: ', $name, '<br />';
print_r($post); <-- get everything in the post array.
echo '</pre>';


      echo '
               <table border="0" width="100%" align="center">
                     <tr>
                                <td><b>', $post['poster']['link'], '</b></td>
                      </tr>
                        <tr>
                                <td>', $post['subject'], '<br /><br /></td>
                    </tr>
                </table>
                <br />';

       if ($post['poster']['name'] == $name) <-- if this poster's name is the same as the name above output the link.
             echo $row['poster']['link'];
}

-[Unknown]

Elijah Bliss

Quote from: [Unknown] on July 03, 2004, 02:18:35 AM
No, no, like this:

foreach ($posts as $post)
{

echo '<pre>Name: ', $name, '<br />';
print_r($post);
echo '</pre>';


      echo '
               <table border="0" width="100%" align="center">
                     <tr>
                                <td><b>', $post['poster']['link'], '</b></td>
                      </tr>
                        <tr>
                                <td>', $post['subject'], '<br /><br /></td>
                    </tr>
                </table>
                <br />';

       if ($post['poster']['name'] == $name)
             echo $row['poster']['link'];
}


Here's a basic rundown:
Quoteforeach ($posts as $post) <-- look at each post.
{ <-- use everything inside these curly braces to look at them.

echo '<pre>Name: ', $name, '<br />';
print_r($post); <-- get everything in the post array.
echo '</pre>';


      echo '
               <table border="0" width="100%" align="center">
                     <tr>
                                <td><b>', $post['poster']['link'], '</b></td>
                      </tr>
                        <tr>
                                <td>', $post['subject'], '<br /><br /></td>
                    </tr>
                </table>
                <br />';

       if ($post['poster']['name'] == $name) <-- if this poster's name is the same as the name above output the link.
             echo $row['poster']['link'];
}

-[Unknown]

copying and pasting your code:
$posts = ssi_recentPosts(5, array(), 'array');
$name = 'MsHoney';

foreach ($posts as $post) //<-- look at each post.
{ //<-- use everything inside these curly braces to look at them.

echo '<pre>Name: ', $name, '<br />';
print_r($post); //<-- get everything in the post array.
echo '</pre>';


      echo '
               <table border="0" width="100%" align="center">
                     <tr>
                                <td><b>', $post['poster']['link'], '</b></td>
                      </tr>
                        <tr>
                                <td>', $post['subject'], '<br /><br /></td>
                    </tr>
                </table>
                <br />';

       if ($post['poster']['name'] == $name) //<-- if this posters name is the same as the name above output the link.
             echo $row['poster']['link'];
}


I get similar results as before:
http://blaqboard.com/testportal.php

is the problem coming from this line?
$posts = ssi_recentPosts(5, array(), 'array');

Elijah Bliss

#26
This is what I have so far:

<?php
require("/***/SSI.php"); 

$posts ssi_recentTopics(2000, array(), 'array');
$id 97;

foreach (
$posts as $post//<-- look at each post.
//<-- use everything inside these curly braces to look at them.
if ($post['poster']['id'] == $id)
echo 
$post['poster']['name'] . '<br />' $post['time'] . '<br />' $post['link'];
echo 
'<pre>';
print_r($post null);
echo 
'</pre>';
}
?>


http://blaqboard.com/testportal.php

[Unknown]

Are you looking for all the posts by a specific member?

-[Unknown]

Elijah Bliss

Quote from: [Unknown] on July 04, 2004, 03:42:44 AM
Are you looking for all the posts by a specific member?

-[Unknown]

Yes, I am.

Actually the just the topics. I solved the formatting problem, the only problem I have now is that anytime someone responds to a recent topic of this poster the topic disappears from the test portal page. I don't want to do "ssi_recentPosts" because I am not interested in this poster's responses, only her topics. Is there anyway to keep her topics on the page?

[Unknown]

You're going through a very round about way... it would be better to just use a specialized SQL query.

$result = db_query("
   SELECT m.ID_TOPIC, m.subject
   FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
   WHERE t.ID_MEMBER_STARTED = the ID of MsHoney here!
      AND m.ID_MSG = t.ID_FIRST_MSG
   LIMIT how many you want", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
   echo '<a href="', $scripturl, '?topic=', $row['ID_TOPIC'], '.0">', $row['subject'], '</a><br />';
}
mysql_free_result($result);

-[Unknown]

Elijah Bliss

Quote from: [Unknown] on July 04, 2004, 05:12:18 PM
You're going through a very round about way... it would be better to just use a specialized SQL query.

$result = db_query("
   SELECT m.ID_TOPIC, m.subject
   FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
   WHERE t.ID_MEMBER_STARTED = the ID of MsHoney here!
      AND m.ID_MSG = t.ID_FIRST_MSG
   LIMIT how many you want", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
   echo '<a href="', $scripturl, '?topic=', $row['ID_TOPIC'], '.0">', $row['subject'], '</a><br />';
}
mysql_free_result($result);

-[Unknown]

I keep getting this error using the SQL query:
Warning: Cannot modify header information - headers already sent by (output started at /***/Sources/Load.php:812) in /***/Sources/Subs.php on line 1599

[Unknown]

You do need to edit out the "how many you want" etc. of course...

-[Unknown]

Elijah Bliss

Quote from: [Unknown] on July 04, 2004, 08:50:04 PM
You do need to edit out the "how many you want" etc. of course...

-[Unknown]

thanks for the help, that's much faster!

One last question:
How do I get the newer topics to order from top to bottom of the page? Right now the newest topic is ordered at the bottom of the page.

[Unknown]

Right before the line that says "LIMIT ...." put another line with "ORDER BY m.ID_MSG DESC".

-[Unknown]

Elijah Bliss

Quote from: [Unknown] on July 04, 2004, 09:51:29 PM
Right before the line that says "LIMIT ...." put another line with "ORDER BY m.ID_MSG DESC".

-[Unknown]

YOU THA MAN! Thanks!

Tom

How would you go about changing the font size of the output? (In my case, the recent posts function.)

Tomer

You could just add a <font size='1'> tag.

Tom

#37
Hehe.. yes that would be the obvious thing to do. I can't believe I didn't think of that.  :-[

Thanks.  :)

Edit: Hmm, it dosen't appear to be working.

[Unknown]

.ssi_table
{
   font-size: 8pt;
}

-[Unknown]

Tom

#39
Thanks !

Edit: Sorry, I really hate to be a pain. It still doesn't appear to be looking. The page is www.pogocheats.net and the CSS is on http://www.pogocheats.net/styles/main_style.css. Thanks very much for your help.

Advertisement: