i made previous post vague. i've done lot of research , think can more specific.
while (!feof($file_handle)) { $loansinfo = fgetcsv($file_handle); // make sure check data game posted if($loansinfo[0]==$id) { $referencedate = $wanteddate; $fromdate = "$loansinfo[5]"; $todate = "$loansinfo[6]"; // convert dates timestamps (strings integers) $referencetimestamp = strtotime( $referencedate ); $fromtimestamp = strtotime( $fromdate ); $totimestamp = strtotime( $todate ); $isbetween = $referencetimestamp >= $fromtimestamp , $referencetimestamp <= $totimestamp; //refuse booking echo('<script type="text/javascript">alert("game booked");</script>'); exit; } } // otherwise execute save code
problem is, 'game booked'. why?
sample csv file data requested:
id, gamename,gamecost, daysrequested, total, reservationstart, dateend 5,pinball, 3.99,7, 27.99, 01/01/2015, 08/01/2015
though should said form requires date entry yyyy-mm-dd
. have java script conversion.
i've seen one! try this:
while (!feof($file_handle)) { $loansinfo = fgetcsv($file_handle); if($loansinfo[0]==$id){ $fromdate = "$loansinfo[5]"; $todate ="$loansinfo[6]"; if (strtotime($dateborrowedfrom) <= strtotime($wanteddate)) { if(strtotime($todate) >= strtotime($wanteddate)){ $cantbook = true; } } else { if (strtotime($dateborrowedfrom) <= strtotime($dateto)) { $cantbook= true; } } } } fclose($file_handle); if($cantbook = true){ echo('<script type="text/javascript">alert("game booked");</script>'); } else{ //saving booking
Comments
Post a Comment