Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Sep 2007
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    posting updated date

    is there a php code that posts the date that the database was last updated?

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Are you asking about any row in the database being updated, or a single row in the table being updated? (The answer is no on the second option-- you must add a timestamp column to your table(s) to track the last update; there may be a way to do it on the first option)

    Also it helps to provide basic info such as the database you are using (i.e. MySQL).

  • #3
    New Coder
    Join Date
    Sep 2007
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts
    to clarify i am using a mysql database and i want the time to be updated every time there is a row added to one of the tables.

    also is there a page that fully explains the different types of fields in a database?

  • #4
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    A time updated that any row is updated? Well, instead of making a separate table for the status of the last update, you can query the table with the rows sorted descending on the date column and use the latest insert/update date. Not too difficult. e.g.

    Code:
    SELECT * FROM news ORDER BY updateTime DESC LIMIT 1
    And use updateTime as the "latest update"
    Last edited by Velox Letum; 11-21-2007 at 03:46 AM.
    "$question = ( to() ) ? be() : ~be();"

  • #5
    New Coder
    Join Date
    Sep 2007
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh well i don't want to change the order i want there to be a thing that says table last updated: and has the date that the most recent row was added

  • #6
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It doesn't change the order. It's the order it retrieves the data in this particular query.

    Code:
    SELECT updateTime FROM news ORDER BY updateTime DESC LIMIT 1
    Will select the time of the latest updated row if your column for updated time is updateTime.
    "$question = ( to() ) ? be() : ~be();"

  • #7
    New Coder
    Join Date
    Sep 2007
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <?php $query="SELECT updateTime FROM members ORDER BY updateTime DESC LIMIT 1" echo $updateTime ?>
    I'm extremely new to php and thats the code i put on the site but its not working
    Last edited by emerald511; 11-22-2007 at 04:00 AM.

  • #8
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I assumed you knew how to use MySQL databases with PHP.

    Check out http://www.php-mysql-tutorial.com/ and other tutorials around the internet, or buy a book.
    "$question = ( to() ) ? be() : ~be();"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •