Jump to content

Select Query


zed420

Recommended Posts

Hi All

This query below works and avoids all the Overlaping BUT only for the first recored and thereafter it overlaps. Any thoughts please ???

Zed

$query = "SELECT COUNT(*) AS Cnt   
     FROM booking   
     WHERE request_date='$request_date'   
     AND e_time > '$s_time'   
     AND s_time < '$e_time'";  

Link to comment
Share on other sites

Thanks for your reply but Unsuccessfull again. This is the background of it, A typical day's diary starts from 0800 till 2100, normally you would book an hr but just to test the script I booked 0800 to 2100 so that means all day has been booked NO other booking can be taken for this day if I DO NOT select the varibles 8 & 21 IT WILL book again and again . ????? why why????? How can I avoid that, s_time and e_time are numbers in database, this is the query I'm using

Thanks Zed

$query = "SELECT b_id, COUNT(*) AS Cnt 
2.FROM booking 
3.WHERE request_date='$request_date' 
4.AND e_time > '$s_time' 
5.AND s_time < '$e_time' 
6.GROUP BY b_id"; 
7.    $result = mysql_query($query); 
8.    $row = mysql_fetch_assoc($result); 
9.    if($row['Cnt'] > 0){ 
10.    error_message('Sorry, this time is already booked. Please choose another'); 
11.            } else { 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.