I have a database with a listing of events. I do not want to include events that have already happened, so I want to query the db for events from the current date going forward. I have tried a number of things but it is not working. Here is what i have so far - in the query

// Get the current date
$Now = time(); 
 
// Make a MySQL Connection
mysql_connect("localhost", "*****", "****") or die(mysql_error());
mysql_select_db("******") or die(mysql_error());

// Get all the data from the table


$result = mysql_query("SELECT * FROM events where Date > $Now order by Date ASC Limit 0,10")
or die(mysql_error());

Any help would be appreciated.
Cheers,
Chris

Recommended Answers

All 2 Replies

try this:

SELECT * FROM events WHERE field3 >= DATE(NOW());

so, all in all from what you have:

// Make a MySQL Connection
mysql_connect("localhost", "*****", "****") or die(mysql_error());
mysql_select_db("******") or die(mysql_error());
// Get all the data from the table
$result = mysql_query("SELECT * FROM events WHERE field3 >= DATE(NOW());")
or die(mysql_error());

Awesome! I tweaked my order by clause and it is all good. Does exactly what I need it to. Thanks so much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.