Jump to content

php overlaping feature


dubc07

Recommended Posts

i received a bit of code here yesterday that will not allow booking between  start and end time.

This thing works great. However if i go to book before start time and into the reservation it allows booking.

 

 

here's the code

 

<?php


$start='630';
$end='900';
$plane = 0;


$q = "SELECT COUNT(*) AS count FROM rentme WHERE plane = $plane AND (starttime BETWEEN '$start' AND '$end' OR endtime BETWEEN '$start' AND '$end' OR '$start' BETWEEN starttime AND endtime OR '$end' BETWEEN starttime AND endtime)";
$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 ';


?>

 

what is listed on the database is a booking in plane 0 from starttime 700 to endtime 1100

 

The example would be someone trying to book from 600 to 1200

would be able to book because the code is not designed to look for outside times or overlapping.

However inside those start and end times as listed above the script works great.

i need both functions. Any help would be great, I'm still new to php.

Link to comment
https://forums.phpfreaks.com/topic/117354-php-overlaping-feature/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.