problem displaying records in order of time and date in php (1 Viewer)

tony007

Registered User.
Local time
Today, 15:42
Joined
Jun 30, 2005
Messages
53
Hi all.I use $Timestamp=date("g:i A l, F j Y."); to collect time and date the visitors entered my site . It inserts the data in to mysql database in this format :



3:02 AM Monday, July 24 2006





Code:
mysql_query("INSERT INTO logdisplay VALUES('$ID','$column1','$Timestamp','$column2','$columns3')");

 

 

$affected_rows = $sql->a_rows;





But when i query the database and use order by ,the data does not get displaied in order of newest on the top!!



Code:
select * from logdisplay order by Timestamp





could any one help me so that i get newst log records on the top .In another how to query my table baced on time an data.Thanks
 
Last edited:

dt01pqt

Certified
Local time
Today, 23:42
Joined
Mar 22, 2004
Messages
271
First you need to use either DATETIME or TIMESTAMP types on that field in the db. These are stored in number only formats (with a delimeter). Text Types will just order as if it is a string. See here for a list of aceptibable formats. Use php to do any formating you would like on the page.


sorting rows

SELECT * FROM logdisplay ORDER BY Timestamp DESC
 
Last edited:

mercy

Registered User.
Local time
Today, 15:42
Joined
Aug 4, 2006
Messages
10
Got it in order, let me know....
 

Users who are viewing this thread

Top Bottom