php+mysql select and order
Posted: Sun Sep 12, 2004 12:40 pm
So this is what my 'threads' table looks like (which is under the database forums').
and I'm sure (through phpmyadmin) that all data is being store there properly.
when i execute this command
the function returns nothing, i guess the sorting is not working....
Can anybody help me?
Code: Select all
threadID forumID creatorID topic firstPost timeCreated lastPostTimewhen i execute this command
Code: Select all
function lastTopic($forumID)
{
$user="root";
$host="localhost";
$password="++++++";
$database="foums";
$connection=mysql_connect($host,$user,$password) or die ("Couldnt connect to server");
$db=mysql_select_db($database,$connection) or die ("Couldnt select database");
$query="SELECT * FROM threads WHERE forumID='$ForumID' ORDER BY lastPostTime DESC";
$result=mysql_query($query) or die ("Query failed to get the last topic");
$data=mysql_fetch_array($result);
$lasttopic=$data['topic'];
return $lasttopic;
}Can anybody help me?