<?php##load product informationdbConnect("Valjeanstageservices");$sqltemp = "SELECT * FROM tbl_products ORDER BY ProductID";$resultproducts = mysql_query($sqltemp);if (!$resultproducts) { echo 'A database error has occurred';}mysql_close();$rowproducts = mysql_numrows($resultproducts);##end of load product information$productidinc=0;#while there is the number of rows in tbl_booking hasnt been outputted output themwhile ($productidinc < $rowproducts) {$ProductID = mysql_result($resultproducts,$productidinc,"ProductID");##connect to database query tbl_booking with product id to see when one product has been bookeddbConnect("Valjeanstageservices");$sql = "SELECT * FROM tbl_booking WHERE ProductID='$ProductID'";$results = mysql_query($sql);if (!$results) { echo 'A database error has occurred';}mysql_close();##check each result from tbl_booking where product id = product id$i=0;$canbebooked = "1";while ($i < $results) {if($canbebooked == "0") { echo 'Light cant be booked'; exit;}$startbookingdate = mysql_result($results,$productidinc,"datebookedfrom");$endbookingdate = mysql_result($results,$productidinc,"datebookedto");##check to see if the light can be booked if so output light##if light cant be booked exit;##converted to the time since epoch$startbookingdate = strtotime($startbookingdate);$endbookingdate = strtotime($endbookingdate);if(($datebookedfrom <= $startbookingdate && $datebookedto >= $endbookingdate) or($datebookedfrom >= $startbookingdate && $datebookedfrom <= $endbookingdate) or($datebookedfrom <= $startbookingdate && $datebookedto >= $startbookingdate) or ($datebookedfrom >= $startbookingdate && $datebookedfrom <= $endbookingdate)) {echo $canbebooked=0;}i++;}if($canbebooked =="1") { echo $ProductID.'Can be booked';}$productidinc++;}?>