coolphpdude Posted April 1, 2008 Share Posted April 1, 2008 Hey again, If im doing a message board type system and i want to arrange messages by date and time how do i do it? at the moment im just selecting all records from my message table where user id=xx then outputting the messages using a while loop Quote Link to comment Share on other sites More sharing options...
ansarka Posted April 1, 2008 Share Posted April 1, 2008 give order by date Quote Link to comment Share on other sites More sharing options...
coolphpdude Posted April 1, 2008 Author Share Posted April 1, 2008 $message_result = mysql_query("SELECT * FROM usermessages WHERE user_id='$user_session_id' ORDER BY date AND time", $db); ??? Quote Link to comment Share on other sites More sharing options...
Xil3 Posted April 1, 2008 Share Posted April 1, 2008 $message_result = mysql_query("SELECT * FROM usermessages WHERE user_id='$user_session_id' ORDER BY date AND time", $db); ??? Change the "AND" between the date and time to a comma (,) as per below: $message_result = mysql_query("SELECT * FROM usermessages WHERE user_id='$user_session_id' ORDER BY date, time", $db); Quote Link to comment Share on other sites More sharing options...
Xil3 Posted April 1, 2008 Share Posted April 1, 2008 You can also add DESC to reverse the order as per below: $message_result = mysql_query("SELECT * FROM usermessages WHERE user_id='$user_session_id' ORDER BY date DESC, time DESC", $db); Quote Link to comment Share on other sites More sharing options...
coolphpdude Posted April 1, 2008 Author Share Posted April 1, 2008 Thanks thats great Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.