I am trying to get something to display from a mysql query using a case statement, but I am having trouble trying to get it to work right. basically, i am trying to get it to display one thing if there is a result that comes back true. but if it doesn't i want it to use a different mysql query and display something else and i am just confused on how to get it to work.
here is my code:
<?php
include 'dbconn.php';
$sql = "select * from picks where expiredate = curdate() and curtime() < expiretime and starttime < curtime();";
$result = mysql_query($sql,$conn);
$anymatches=mysql_num_rows($result);
if ($anymatches == 0)
{
$sql = "select * from picks where expiredate > curdate() order by expiredate asc limit 1;";
$result = mysql_query($sql,$conn);
echo <<<END
<div align="center">There is no pick available at this time $edate</div>
END;
}
while ($row = mysql_fetch_array($result)){
$pick = $row['pick'];
$event = $row['event'];
$starttime = $row['starttime'];
$endtime = $row['expiretime'];
$enddate = $row['expiredate'];
$etime = ( date("g:i a", strtotime($endtime)) );
$stime = ( date("g:i a", strtotime($starttime)) );
$edate = ( date("m/d/Y", strtotime($enddate)) );
echo <<<END
<div align="center">This current pick is available:<br />
$event<br />
END;
}
?>
more or less this is the part that i am having trouble with:
if ($anymatches == 0)
{
$sql = "select * from picks where expiredate > curdate() order by expiredate asc limit 1;";
$result = mysql_query($sql,$conn);
echo <<<END
<div align="center">There is no pick available at this time $edate</div>
END;
}
I am not sure what needs to happen there, I guess. I thought that I had this working, but I guess not.