View Full Version : posting updated date
11-20-2007, 06:19 AM
is there a php code that posts the date that the database was last updated?
11-20-2007, 07:31 AM
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).
11-21-2007, 04:42 AM
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?
11-21-2007, 04:44 AM
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.
SELECT * FROM news ORDER BY updateTime DESC LIMIT 1
And use updateTime as the "latest update"
11-21-2007, 05:11 AM
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
11-21-2007, 06:07 AM
It doesn't change the order. It's the order it retrieves the data in this particular query.
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.
11-22-2007, 04:53 AM
<?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
11-22-2007, 05:27 AM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.