Date solved! And now TIME problems : Booking by Date/Time

From: Date: Wed, 21 Mar 2001 08:37:26 +0000
Subject: Date solved! And now TIME problems : Booking by Date/Time
Groups: php.general 
Request: Send a blank email to php-general+get-44903@lists.php.net to get a copy of this message
i was able to succesfully check for start dates & end dates before feeding new booking in the database using the following code : <?php $db = mysql_connect("localhost","root"); mysql_select_db("nidc_intranet",$db); $realsdate="$syear"."-"."$smonth"."-"."$stdate"; $realedate="$eyear"."-"."$emonth"."-"."$endate"; $realstime="$shh".":"."$smm".":"."00"." "."$sttime"; $realetime="$ehh".":"."$emm".":"."00"." "."$entime"; $result = mysql_query("select * from booking where ('$realsdate'>=sdate and '$realsdate'<=edate) or ('$realedate'>=sdate and '$realedate'<=edate)",$db); if (mysql_num_rows($result)) { ?> <script language="javascript"> alert('Sorry, the room is already booked for the period. Please choose a different period'); history.go(-1); </script> <? } else { $sql = "INSERT INTO booking (room,sdate,edate,stime,etime,purpose,reserved) VALUES ('$rooms','$realsdate','$realedate','$realstime','$realetime','$purpose','$res')"; $result = mysql_query($sql) or Die ("An unexpected error occured. Please go back and book again."); echo "<font face=helvetica size=2 color=#140057><b>Thank you! <font color=#ff0000>$rooms</font>, has been booked from <font color=#ff0000>$realsdate</font> to <font color=#ff0000>$realedate</font>. <br><br> ** Entries will be deleted 2 weeks after the End Date. "; } ?> But now - TIME problems. I have to check for the same on TIME as well - the problem is - he needs to check for the TIME in that Particular row only...and not as a whole. For eg :- if there's a Booking from 1st August 2001 1:00 p.m. to 1st August 2001 3:00 p.m. (same day), and if someone wants to make a booking for the same day from 4:00 p.m. to 6:00 p.m., my code doesn't allow that. Because he checks for the DATE - and as soon as he will find 1st August, he won't allow a booking to be made for that same day. What do i do?? I know the changes have to be made here : $result = mysql_query("select * from booking where ('$realsdate'>=sdate and '$realsdate'<=edate) or ('$realedate'>=sdate and '$realedate'<=edate)",$db); but i dodn't know what changes. Please HELP!! Cheers, T. Edison jr. ===== Rahul S. Johari (Director) ****************************************** Abraxas Technologies Inc. Homepage : http://www.abraxastech.com Email : abraxastech@yahoo.com Tel : 91-4546512/4522124 ******************************************* __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/

« previous php.general (#44903) next »