FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » 2.6.x Recent posts list with date and time
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: THE CODE! for Recent posts list with date and time [message #22380 is a reply to message #21207] Mon, 31 January 2005 09:17 Go to previous messageGo to previous message
cellarius is currently offline  cellarius   Germany
Messages: 6
Registered: January 2005
Location: Augsburg/Germany
Karma:
Junior Member
Hi,

try this - works fine for me:

<?php
function fetch_forum_posts($n_posts) /* n_posts is the number of messages you wish to fetch */
{
        include_once "GLOBALS.php";

        $cid = mysql_connect($DBHOST, $DBHOST_USER, $DBHOST_PASSWORD);
        $tbl = $DBHOST_TBL_PREFIX;
        $r = mysql_db_query($DBHOST_DBNAME, "SELECT resource_id
                                                FROM ".$tbl."group_cache
                                                WHERE user_id=0
                                                AND group_cache_opt>>1&1=1", $cid);
        $lm='';
        while( list($id) = mysql_fetch_row($r) ) $lm .= $id.',';
        $lm = substr($lm, 0, -1);

        $r = mysql_db_query($DBHOST_DBNAME, "SELECT
                                                ".$tbl."msg.id,
                                                ".$tbl."msg.subject,
                                                ".$tbl."thread.last_post_date,
                                                ".$tbl."thread.last_post_id,
                                                ".$tbl."thread.views,
                                                ".$tbl."thread.replies,
                                                ".$tbl."msg.poster_id,
                                                ".$tbl."users.alias
                                        FROM
                                                ".$tbl."thread
                                        INNER JOIN ".$tbl."msg
                                                ON ".$tbl."thread.root_msg_id=".$tbl."msg.id
					INNER JOIN ".$tbl."users
						ON ".$tbl."msg.poster_id=".$tbl."users.id	
                                        WHERE
                                                ".$tbl."thread.forum_id IN (".$lm.") AND
                                                ".$tbl."msg.apr=1
                                        ORDER by
                                                ".$tbl."thread.last_post_id DESC
                                        LIMIT ".$n_posts, $cid);
        while( $obj = mysql_fetch_object($r) ) {
                /* Here you do your actual code, below is a working example */
        $tm = date("d/m/Y H:i", $obj->last_post_date);
			    print "<tr>";
                print "<td class=\"RowStyleA\">#</td>";
                print "<td  class=\"RowStyleB\">";
                print "<a title=\"??????? ? ????\" mclass =\"menubar\" href=\"";
                print $WWW_ROOT . "index.php?t=msg&goto=" . $obj->id . "\"><b> " . $obj->subject;
                print "</b></a></td>";
                print "<td  class=\"RowStyleA\">";
                print strftime("%d %b %H:%M", $obj->last_post_date);
                print "</td>";
                print "<td class=\"RowStyleB\" align=\"center\">". $obj->replies ." / ". $obj->views . "</td>";
                print "<td class=\"RowStyleA\" align=\"center\"><a class=\"GenLink\" href=\"";
                print $WWW_ROOT ."index.php?t=usrinfo&id=". $obj->poster_id. "\">". $obj->alias ."<br></td></tr>";
        }
        mysql_free_result($r);
}
?>
<?php
fetch_forum_posts(34);
?>


HTH,

Sven
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon4.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Extra User Info
Next Topic: Email Participation patch
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun May 19 07:29:55 GMT 2024

Total time taken to generate the page: 0.04860 seconds