problem displaying records in order of time and date in php
-
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;[/CODE] 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[/CODE] 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 :confused:
-
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;[/CODE] 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[/CODE] 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 :confused:
Try it, select * from logdisplay order by Timestamp DESC
-
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;[/CODE] 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[/CODE] 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 :confused:
-
select * from logdisplay order by Timestamp use your timestamp field name in database instead of Timestamp word in above as below for sample: select * from logdisplay order by field1
Human knowlege belongs to the world
so could any one show me the insert statemts that records both time and date in a way that can be quried and sorted baced on time and date. The page is triggered when a visitor visits my page and i records its visit history and later on show the logs baced on time and date of visits.Thanks
-
so could any one show me the insert statemts that records both time and date in a way that can be quried and sorted baced on time and date. The page is triggered when a visitor visits my page and i records its visit history and later on show the logs baced on time and date of visits.Thanks
-
use this commands in your mysql query: UNIX_TIMESTAMP FROM_UNIXTIME
Human knowlege belongs to the world