dubc07 Posted August 1, 2008 Share Posted August 1, 2008 on my database i have 2 sets of times booked. a starttime of 700 and endtime of 1000 a starttime of 1400 and endtime of 1600 now if i try and book from 600 to 1500 which is 3pm military this program counts and works good but if i book from 600 to 2200 the count comes back 0 and allows over booking. hows this possible and is there a solution? <?php $month = 'September'; $day = '10'; $start='600'; $end='2200'; $plane = 0; $q = 'SELECT COUNT(*) AS count FROM rentme WHERE `month`="'.$month.'" AND `day`="'.$day.'" AND `plane`="'.$plane.'" AND ( "'.$start.'"BETWEEN starttime AND endtime OR "'.$end.'" BETWEEN starttime AND endtime OR starttime BETWEEN "'.$start.'" AND "'.$end.'" OR endtime BETWEEN "'.$end.'" AND "'.$start.'" OR starttime BETWEEN "'.$end.'" AND "'.$start.'" )'; $sql = mysql_query($q); $count = mysql_result($sql, 0, 'count'); if ($count > 0) { echo $count; die('you may not book here'); } echo ' you made it '; echo $count; ?> Quote Link to comment Share on other sites More sharing options...
dubc07 Posted August 1, 2008 Author Share Posted August 1, 2008 any ideas at all ? Quote Link to comment Share on other sites More sharing options...
ainoy31 Posted August 1, 2008 Share Posted August 1, 2008 have you just tried using: AND ( "'.$start.'"BETWEEN starttime AND endtime OR "'.$end.'" BETWEEN starttime AND endtime) seems like you are doing redundant comparison. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.