I have a mySQL database with in it:
usernames
email-addresses &
date/time
The date/time is altered whenever a user changes his email-adress.
Now I want to use this time/date to make an output to the screen like:
The email-list is <'time/date'> updated.
How can I retrieve, at all times, the latest update date/time??
This date/time needs to change whenever a (random) user alters his email-adress.
Extra info:
The field in MySQL for date/time is called "lastupdate".
Thanx in advance.
[S]Can I use date/time in a table to view the latest update?
Moderator: General Moderators
-
Braindead)1
- Forum Newbie
- Posts: 8
- Joined: Sat Jan 31, 2004 6:44 am
-
Braindead)1
- Forum Newbie
- Posts: 8
- Joined: Sat Jan 31, 2004 6:44 am
-
Braindead)1
- Forum Newbie
- Posts: 8
- Joined: Sat Jan 31, 2004 6:44 am
Nope, still no result.
I tried:
SELECT lastupdate FROM usermail ORDER BY lastupdate DESC LIMIT 1
inhere, lastupdate is the fieldname and usermail is the tablename.
When I try:
$update = 'SELECT lastupdate FROM usermail ORDER BY lastupdate DESC LIMIT 1';
echo $update;
the result is that the exact text between '' is produced on the screen, not the value from the table.
I get the same result if I put the entire SELECT-command in "".
?????????
I'm puzzled now, because I was tought that information between "" would result into a variable, while between '' the output would be exactly what you put between them.
I tried:
SELECT lastupdate FROM usermail ORDER BY lastupdate DESC LIMIT 1
inhere, lastupdate is the fieldname and usermail is the tablename.
When I try:
$update = 'SELECT lastupdate FROM usermail ORDER BY lastupdate DESC LIMIT 1';
echo $update;
the result is that the exact text between '' is produced on the screen, not the value from the table.
I get the same result if I put the entire SELECT-command in "".
?????????
I'm puzzled now, because I was tought that information between "" would result into a variable, while between '' the output would be exactly what you put between them.
Er...yeah...
$update = 'SELECT lastupdate FROM usermail ORDER BY lastupdate DESC LIMIT 1'; won't actually run a query for you, it's just a string..
You want something along the lines of..
$update = 'SELECT lastupdate FROM usermail ORDER BY lastupdate DESC LIMIT 1'; won't actually run a query for you, it's just a string..
You want something along the lines of..
Code: Select all
$db = mysql_connect('localhost', 'user', 'password') or die(mysql_error());
mysql_select_db('thedbname') or die(mysql_error());
$query = 'SELECT lastupdate FROM usermail ORDER BY lastupdate DESC LIMIT 1';
$result = mysql_query($query) or die(mysql_error());
if(mysql_num_rows($result) > 0){
$row = mysql_fetch_assoc($result);
echo $row['lastupdate'];
} else {
echo 'No rows returned!';
}-
Braindead)1
- Forum Newbie
- Posts: 8
- Joined: Sat Jan 31, 2004 6:44 am