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

Home » FUDforum Development » Plugins and Code Hacks » Looking for hack...
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Looking for hack... [message #8594 is a reply to message #5630] Mon, 10 February 2003 16:34 Go to previous messageGo to previous message
Sergey is currently offline  Sergey   United States
Messages: 41
Registered: January 2003
Karma:
Member
kewlguy wrote on Tue, 10 September 2002 17:55

Ok, finally got it to work, it took this code:
<?php
// n_posts is the number of messages you wish to fetch
function fetch_forum_posts($n_posts)
{
include_once "/path/to/GLOBALS.php";

$cid = mysql_connect($DBHOST, $DBHOST_USER, $DBHOST_PASSWORD);
$r = mysql_db_query($DBHOST_DBNAME, "SELECT resource_id FROM ".$DBHOST_TBL_PREFIX."group_cache WHERE user_id=0 AND p_READ='Y'", $cid);
$lm='';
while( list($id) = mysql_fetch_row($r) ) $lm .= $id.',';
$lm = substr($lm, 0, -1);
$r = mysql_db_query($DBHOST_DBNAME, "SELECT ".$DBHOST_TBL_PREFIX."msg.id, ".$DBHOST_TBL_PREFIX."msg.subject
FROM ".$DBHOST_TBL_PREFIX."thread INNER JOIN ".$DBHOST_TBL_PREFIX."msg
ON ".$DBHOST_TBL_PREFIX."thread.root_msg_id=".$DBHOST_TBL_PREFI X."msg.id
WHERE ".$DBHOST_TBL_PREFIX."thread.forum_id IN (".$lm.") AND
".$DBHOST_TBL_PREFIX."msg.approved='Y' ORDER by ".$DBHOST_TBL_PREFIX."thread.id DESC LIMIT ".$n_posts, $cid);

while( $obj = mysql_fetch_object($r) ) {
// Here you do your actual code, below is a working example
print "» &nbsp;<a class =\"menubar\" href=\"";
print $WWW_ROOT . "index.php?t=msg&goto=" . $obj->id . "\" target=\"_blank\">" . $obj->subject;
print "</a><br>\n";
}

mysql_free_result($r);

}
?>

Thanks everyone!


I am trying to do recent posts on my forum also, but can not to get it work correctly Confused . Just getting a blank page...

Can I ask where I need to put this code Rolling Eyes :

1. As a separate .php page in forum/default directory?
2. As a some kind of template where all templates are?
3. As a .php somewhere and then call it as <? php include ?> in page where I want to see resent posts?
4. As a function somewhere in existing file?

Thanx everybody who can help me on this one!


-------------------
"If you really want something in this life you have to work for it.
Now quiet, they're about to announce the lottery numbers."
Author: Homer Simpson.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon5.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon9.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon9.gif
Read Message
Read Message
Read Message
Read Message
Previous Topic: New threads on the front page of the site
Next Topic: General Hacking Recommendation please
Goto Forum:
  

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

Current Time: Tue May 07 20:40:42 GMT 2024

Total time taken to generate the page: 0.04622 seconds