Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. problem displaying records in order of time and date in php

problem displaying records in order of time and date in php

Scheduled Pinned Locked Moved Web Development
databasehelpphpmysqltutorial
6 Posts 3 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    method007
    wrote on last edited by
    #1

    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:

    A R 2 Replies Last reply
    0
    • M method007

      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:

      A Offline
      A Offline
      Aslam Bari
      wrote on last edited by
      #2

      Try it, select * from logdisplay order by Timestamp DESC

      1 Reply Last reply
      0
      • M method007

        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:

        R Offline
        R Offline
        Reza Raad
        wrote on last edited by
        #3

        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

        M 1 Reply Last reply
        0
        • R Reza Raad

          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

          M Offline
          M Offline
          method007
          wrote on last edited by
          #4

          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

          R 1 Reply Last reply
          0
          • M method007

            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

            R Offline
            R Offline
            Reza Raad
            wrote on last edited by
            #5

            use this commands in your mysql query: UNIX_TIMESTAMP FROM_UNIXTIME

            Human knowlege belongs to the world

            M 1 Reply Last reply
            0
            • R Reza Raad

              use this commands in your mysql query: UNIX_TIMESTAMP FROM_UNIXTIME

              Human knowlege belongs to the world

              M Offline
              M Offline
              method007
              wrote on last edited by
              #6

              which one ? how to use it in insert statemtn and how to query the table so i get output baced on time and date user entered my site.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups