Jump to content

sql query to show recently added items


bobicles2

Recommended Posts

if you set the default to current_time/NOW() it should be fine

 

mysql_connect(localhost,$username,$password);

@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM Events ORDER BY timestamp DESC LIMIT 10";

$result=mysql_query($query);

$num=mysql_numrows($result);

 

i use this, and it works and echo's everything fine when i used the query

 

SELECT * FROM Events

 

but doesnt work with the new query despite me having a timestamp field in my database having the default as timestamp i checked my databse and when i add an entry the timestamp is added so im not sure whats going wrong

if SELECT * FROM Events ORDER BY timestamp DESC LIMIT 10 works why are you using  SELECT * FROM Events  ?

 

sorry i meant it to mean it doesnt work... but when i used Select * From Events it works fine.. so theres a problem with the query

 

ive solved this now though using a different method..i have a field for ID which is set to auto increment so just changed it to display the 10 highest ID's (which are obviously the most recently added events)

 

thanks for the help though much appreciated!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.