paddyfields
04-14-2012, 02:21 PM
Hi, this is frustratingly simple but i can't work out the problem
I want to find the next upcoming event in the database... by looking at the event date. I'm doing this by storing todays date as $todaysdate and then in the WHERE clause looking for "gigdate >= $todaysdate". The gigdate field is formatted as 'date' in the database (so stored as 2012-12-01 etc..).
$todaysdate = date("Y-m-d");
$findnextgig = mysql_query("SELECT * FROM gig WHERE venueid = $thevenue AND gigdate >= $todaysdate");
if($nextgig = mysql_fetch_array($findnextgig)){
echo $nextgig['gigid'];
}
else
{
echo "<p>no upcoming gigs</p>";
}
I have 3 piece of test data in the table, each 2011, 2012, and 2013 dates. And it keeps showing the ID for the 2011 date?
I want to find the next upcoming event in the database... by looking at the event date. I'm doing this by storing todays date as $todaysdate and then in the WHERE clause looking for "gigdate >= $todaysdate". The gigdate field is formatted as 'date' in the database (so stored as 2012-12-01 etc..).
$todaysdate = date("Y-m-d");
$findnextgig = mysql_query("SELECT * FROM gig WHERE venueid = $thevenue AND gigdate >= $todaysdate");
if($nextgig = mysql_fetch_array($findnextgig)){
echo $nextgig['gigid'];
}
else
{
echo "<p>no upcoming gigs</p>";
}
I have 3 piece of test data in the table, each 2011, 2012, and 2013 dates. And it keeps showing the ID for the 2011 date?