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

Home » FUDforum Development » Plugins and Code Hacks » last posts help
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
last posts help [message #30540] Wed, 01 March 2006 23:01 Go to next message
oswdcn is currently offline  oswdcn   China
Messages: 5
Registered: March 2006
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
<?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($lm0, -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."forum.id
                                        FROM
                                                "
.$tbl."thread
                                        INNER JOIN "
.$tbl."msg
                                                ON "
.$tbl."thread.root_msg_id=".$tbl."msg.id
                                        INNER JOIN "
.$tbl."msg
                                                ON "
.$tbl."forum.id=".$tbl."msg.id
                                                
                                        WHERE
                                                "
.$tbl."thread.forum_id IN (".$lm.") OR
                                                "
.$tbl."msg.apr=1 OR ".$tbl."forum.id=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);
                echo 
"<SPAN CLASS=\"date\">".$tm."</SPAN> - <img src=http://fi7pyu.free.fr/bbs/theme/default/images/goto.gif vspace=3 align=middle>
                <a href=\""
.$WWW_ROOT."index.php?t=msg&goto=".$obj->id."\">".$obj->subject."</a>
                <a href=\""
.$WWW_ROOT."index.php?t=tree&goto=".$obj->last_post_id."\">&raquo;&raquo;</a><br>\n";
        }
        
mysql_free_result($r);
}
?>
<?php
fetch_forum_posts
(30);
?>


Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /www/users/oswd.cn/fudforum/1.php on line 35

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /www/users/oswd.cn/fudforum/1.php on line 42

------------
Why???
Re: last posts help [message #30543 is a reply to message #30540] Thu, 02 March 2006 09:04 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
Your query has failed, use mysql_error() function to see why.

FUDforum Core Developer
Re: last posts help [message #30550 is a reply to message #30540] Thu, 02 March 2006 10:29 Go to previous messageGo to next message
oswdcn is currently offline  oswdcn   China
Messages: 5
Registered: March 2006
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
Laughing 谢谢你们能写出这么好的论坛!我正在学习FUDforum论坛 Laughing
Re: last posts help [message #30551 is a reply to message #30540] Thu, 02 March 2006 10:32 Go to previous messageGo to next message
oswdcn is currently offline  oswdcn   China
Messages: 5
Registered: March 2006
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
Ilia :
你们的论坛做的非常棒,我想做到下面图上的效果,能写出一段代码给我参考以下吗??
index.php?t=getfile&id=2405&private=0
  • Attachment: fudforum.gif
    (Size: 27.47KB, Downloaded 1000 times)
Re: last posts help [message #30552 is a reply to message #30551] Thu, 02 March 2006 10:37 Go to previous messageGo to next message
oswdcn is currently offline  oswdcn   China
Messages: 5
Registered: March 2006
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
(Above->)
How can such a change?
Re: last posts help [message #30620 is a reply to message #30552] Sun, 05 March 2006 11:31 Go to previous message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
Are those links forums? The compact view setting in the forum control panel is what you are looking for I think.

FUDforum Core Developer
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: top_title_code
Next Topic: fud_fetch_msg where is the message text?
Goto Forum:
  

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

Current Time: Sun Oct 22 09:57:55 EDT 2017

Total time taken to generate the page: 0.00667 seconds