How to get messages from a particular forum [message #30591] |
Fri, 03 March 2006 14:13 |
acollins22
Messages: 11 Registered: June 2005 Location: Leicestershire, England
Karma: 0
|
Junior Member |
|
|
Hi Folks,
I'd like to get the last 20 posts from one articular forum to display on a page.
Having read the various threads here I decided to go the FUDapi way. As there isn't a function to do exactl what I want I'd like to write on based on fud_fetch_recent_msg and that's where I come unglued.
fud_fetch_recent_msg reads as...
function fud_fetch_recent_msg($arg=1)
{
$range = time() - 86400 * (float) $arg;
return _fud_msg_multi(0, "SELECT id FROM ".$GLOBALS['DBHOST_TBL_PREFIX']."msg WHERE apr=1 AND post_stamp > ".$range);
}
so I figure I should change arg to be the forum number I want and change the WHERE clause to match the forum_id to $arg and that's the rub, I don't know what the row title is for the forum_id.
What I have is...
function fetch_forum_msg($arg=5)
{
return _fud_msg_multi(0, "SELECT id FROM ".$GLOBALS['DBHOST_TBL_PREFIX']."msg WHERE apr=1 AND forum_id = ".$arg);
}
Am I on the right track? If so could you please point me at the correct clause syntax?
Thanks.
Andy.
|
|
|
Re: How to get messages from a particular forum [message #30623 is a reply to message #30591] |
Sun, 05 March 2006 16:55 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
Close but not quite, the message table does not have a forum_id column, the thread table does. So you need to join the two tables together by thread_id and then your query will work.
FUDforum Core Developer
|
|
|
|
|