I dont know if this is the right categorie to ask,
but how do i sort on date (oldest as last and newest as first)
when $date is for my date and $row["time"] is for my time ?
[SOLVED]Sorting on date?
Moderator: General Moderators
[SOLVED]Sorting on date?
Last edited by Diod on Tue Oct 19, 2004 12:25 pm, edited 2 times in total.
Append this to your mysql query:
This man page might help you out:
http://dev.mysql.com/doc/mysql/en/Sorting_rows.html
Code: Select all
order by time deschttp://dev.mysql.com/doc/mysql/en/Sorting_rows.html
if i understand it correctly, i just do
EDIT: it works, even without order by time..
it seems to order by date AND time even if i only use date
Code: Select all
$result = mysql_query("SELECT * FROM news order by date, time desc",$db);EDIT: it works, even without order by time..
it seems to order by date AND time even if i only use date
At first i also used 2 fields, however if you have multiple time and dates in your database like i did double the fields.. For instance i had 3 fields for time and 3 fields for date so basically 6 fields, i changed that to 3 fields.
And did an order by date,'dd-mm-yyyy hh:mm:ss' desc (european notation)..
Looked around at the mysql help and you can filter out all the values for day, month, year with something like %m or so.. Have a look at the manual for the exact stripping...
Hope this helps a bit..
And did an order by date,'dd-mm-yyyy hh:mm:ss' desc (european notation)..
Looked around at the mysql help and you can filter out all the values for day, month, year with something like %m or so.. Have a look at the manual for the exact stripping...
Hope this helps a bit..