What I need to do is query a table based on a date. Then, if the query returns a "W" or an "H", I need to add one day to the date, then run the query again, until it doesn't return either a "W" or an "H".
My code works fine when the initial query doesn't return a W or H, but when it does, it times out, seemingly in and endless loop. So clearly, something I'm doing with the loop isn't correct.
Can someone help with my logic? Thanks very much from this first time visitor to PHP Freaks!
Here's the code:
<?
$testdate = date("Y-m-d", strtotime("2012/09/30"));
include("includes/databasedateretrieval.inc");
$dateverify = mysql_result($date_result,0,"1_day");
$dfresult = $dateverify;
// Check for dating errors
while ($dfresult == "W" || $dfresult == "H"){
//convert the date to time
$todaydate = strtotime($testdate);
//add 1 day to the date
$todaydate = $todaydate + (24*60*60);
//convert the date back to a format compatible with the table data
$testdate = date("Y-m-d", $todaydate);
//here I'm querying the table again to see if the new date returns a W or H
$dateverify = mysql_result($date_result,0,"1_day");
$dfresult = $dateverify;
}
?>
<? echo $testdate; ?>