View Full Version : Stupidly simple question
filburt1
03-19-2002, 11:48 PM
Given a threadid (and forumid, if it makes a difference), how can I get the contents of the first post in a thread?
Freddie Bingham
03-20-2002, 02:59 AM
$DB_site->query("SELECT * FROM post WHERE threadid = " . intval($threadid) . " ORDER BY dateline DESC LIMIT 1");
.. eh something like that
Freddie Bingham
03-20-2002, 03:01 AM
in vb3 you are going to need to do this as no variables will be available in the global scope:
$DB_site->query("SELECT * FROM post WHERE threadid = " . intval($_REQUEST['threadid']) . " ORDER BY dateline DESC LIMIT 1");
filburt1
03-20-2002, 11:40 PM
Didn't quite work:$postcontents = $DB_site->query("SELECT * FROM post WHERE threadid = $threadid ORDER BY dateline DESC LIMIT 1");
print $postcontents;
It shows "Resource id #8" instead of the post contents :confused:
JamesUS
03-21-2002, 05:25 AM
After that query run:
echo $post[pagetext];
Admin
03-21-2002, 05:38 AM
Actually you need to use query_first(), not query()...
filburt1
03-21-2002, 10:01 AM
Thanks, a combinations of those two suggestions fixed it :)
filburt1
03-21-2002, 02:42 PM
It has to be ASC, not DESC, BTW, it was returning the last post :)
Admin
03-21-2002, 02:45 PM
Oh yeah, that too. You can remove the ASC really, it's not needed. :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.