MySQL order of records, how?
Posted: Sun May 18, 2003 10:11 am
I have a news script and a guestbook script (that I wrote). They seem to work fine, but 'sometimes' the posts get out of order. Like I would post 1 thing and it would stay on top, now MySQL adds records to the end, so my loop reads them backwards, placing the newest on top, I do not have an ID, but how does this get sorted? How would I put a unique ID if I need one.
here is my loop code for my guestbook:
here is my loop code for my guestbook:
Code: Select all
$results = mysql_query("SELECT * FROM gbtable");
$NumOfRows = mysql_numrows($results);
$r = $NumOfRows;
while($r > 0)
{
--$r;
$r_Nick = mysql_result($results, $r, 'Nick');
$r_Nick_IP = mysql_result($results, $r, 'Nick_IP');
$r_Email = mysql_result($results, $r, 'Email');
$r_Body = mysql_result($results, $r, 'Body');
$r_PostDate = mysql_result($results, $r, 'PostDate');
ShowComment($r_Nick, $r_Nick_IP, $r_Email, $r_Body, $r_PostDate); #this just prints out a table with the info.
}