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 Link to comment https://forums.phpfreaks.com/topic/98972-sort-by/ Share on other sites More sharing options...
ansarka Posted April 1, 2008 Share Posted April 1, 2008 give order by date Link to comment https://forums.phpfreaks.com/topic/98972-sort-by/#findComment-506423 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); ??? Link to comment https://forums.phpfreaks.com/topic/98972-sort-by/#findComment-506424 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); Link to comment https://forums.phpfreaks.com/topic/98972-sort-by/#findComment-506435 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); Link to comment https://forums.phpfreaks.com/topic/98972-sort-by/#findComment-506437 Share on other sites More sharing options...
coolphpdude Posted April 1, 2008 Author Share Posted April 1, 2008 Thanks thats great Link to comment https://forums.phpfreaks.com/topic/98972-sort-by/#findComment-506523 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.