Jump to content

ORDER BY date DESC problem

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
Thevenin

Thevenin

    Learning Programmer

  • Members
  • PipPipPip
  • 58 posts
Hi all.
As you can understand by the title, I have a problem to order my news by date desc.

This is the variable that contains the date:
$id_col_date = date("d F Y, H:i:s");

and here it is the query to display the news:
$query=" S_ELECT * FROM MyTable ORDER BY id_col_date DESC";


$result=mysql_query($query);

	echo mysql_error();

And now the problem.

My data are displayed in this wrong way:

Quote

News 1 <----> 31 March 2010, 07:37:37
News 2 <----> 30 March 2010, 08:26:32
News 3 <----> 29 March 2010, 16:02:26
News 4 <----> 01 April 2010, 10:12:24
News 5 <----> 01 April 2010, 10:08:51


Instead of this right way:

Quote

News 4 <----> 01 April 2010, 10:12:24
News 5 <----> 01 April 2010, 10:08:51
News 1 <----> 31 March 2010, 07:37:37
News 2 <----> 30 March 2010, 08:26:32
News 3 <----> 29 March 2010, 16:02:26

Any hint on how to fix this problem?

Thank you in advance!

#2
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts
Try viewing this thread to see if that helps.

mysql Order by date DESC [Archive] - PHPBuilder.com
-CDG10620
Software Developer

#3
Thevenin

Thevenin

    Learning Programmer

  • Members
  • PipPipPip
  • 58 posts
Thank you, this morning I've tried this way but I did a mistake in the query.
Now quite all works, and I tink I have to rebuild the entire database cause have problem with new adds!

Thank you, SOLVED!

#4
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts
Glad you got the issue resolved. :)
-CDG10620
Software Developer

#5
webcodez

webcodez

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
Another option would be to just use timestamps instead, which I think is a lot easier and beside that more 'precise' for putting inside database, and easier to sort on of course. But seems you got it working anyway =].