I do get your message Jeff, but tell me, after having
used the following code ..

select * from booking where
    ('$start'>=startdate and '$start'<=enddate) or
    ('$end'>=startdate and '$end'<=enddate)

what code should be written to actually insert booking
data into the table? Because this is basically picking
up data or booking from the Table that fall in this
period. What i want to do is to check if any booking
has been made for this period that i'm inserting
now....

T. Edison jr.

--- Jeff Armstrong <[EMAIL PROTECTED]> wrote:
> One problem is that you are only checking the first
> booking.
>   select * from booking where room='room'
> gives ALL bookings, and you look like you are just
> testing
> the FIRST one.
> 
> why not turn it round and do:
>   select * from booking where
>     ('$start'>=startdate and '$start'<=enddate) or
>     ('$end'>=startdate and '$end'<=enddate)
> 
> This lets mySQL do the test for you.
> If it returns a row you already have a booking.
> 
> 
> -----Original Message-----
> From: Thomas Edison Jr.
> [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, March 20, 2001 11:50 AM
> To: Peter Chr. Hansen
> Cc: [EMAIL PROTECTED]
> Subject: Re: SV: [PHP] Booking by Date/Time in mySQL
> 
> 
> Peter,
> 
> what do you mean by Newdate between date1 & date2??
> the logic i'm using is that i'm checkin if the new
> Start Date & End date lies between the old Start
> Date
> & End Date or not. If it does, than entry is denied,
> else booking is succesfull. But things are not
> running, following is the code i'm using ...
> ----------
> <?php
>     $db = mysql_connect("localhost","root");
>     mysql_select_db("nidc_intranet",$db);
> 
>     $realsdate="$syear"."-"."$smonth"."-"."$stdate";
>     $realedate="$eyear"."-"."$emonth"."-"."$endate";
>     $realstime="$shh".":"."$smm"." "."$sttime";
>     $realetime="$ehh".":"."$emm"." "."$entime";
> 
> $result = mysql_query("SELECT * FROM booking where
> room='$rooms',$db);
> if ($myrow = mysql_fetch_array($result)) {
>   do {
> if ($realsdate>=$myrow[sdate]) &&
> ($realsdate<=$myrow[edate]) &&
> ($realedate>=$myrow[sdate]) &&
> ($realedate<=$myrow[edate]) {
> echo "Sorry";
> }
> else {
> 
>     $sql = "INSERT INTO booking
> (room,sdate,edate,stime,etime,purpose,reserved)
> VALUES
>
('$rooms','$realsdate','$realedate','$realstime','$realetime','$purpose','$r
> es')";
>     $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.
>     ";
> }
>   } while ($myrow = mysql_fetch_array($result));
> }
>      ?>
> ------------
> 
> Regards,
> T. Edison jr.
> 
> --- "Peter Chr. Hansen" <[EMAIL PROTECTED]> wrote:
> > Can't you use "
> >     Newdate between date1 and date2
> >
> >
> > -----Oprindelig meddelelse-----
> > Fra: Thomas Edison Jr.
> > [mailto:[EMAIL PROTECTED]]
> > Sendt: 20. marts 2001 12:25
> > Til: [EMAIL PROTECTED]
> > Emne: [PHP] Booking by Date/Time in mySQL
> >
> >
> > I'm facing this problem.
> > I have made a room booking application.
> > There is a Start Date & Time and End Date & Time
> of
> > Booking a room.
> >
> > Problem is that once booked, you can't book a room
> > with a date or time that falls between an Already
> > booked  Date & Time.
> >
> > For example, if someone's booked a room from 3rd
> > March
> > to 10th March between 4:00 p.m. to 12:00 p.m. ,
> you
> > can't book the same room for the any date between
> > 3rd
> > March to 10th March and between 4 pm & 12 pm.
> >
> > How do i do that?
> >
> > Regards,
> > T. Edison jr.
> >
> >
> > =====
> > Rahul S. Johari (Director)
> > ******************************************
> > Abraxas Technologies Inc.
> > Homepage : http://www.abraxastech.com
> > Email : [EMAIL PROTECTED]
> > Tel : 91-4546512/4522124
> > *******************************************
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Get email at your own domain with Yahoo! Mail.
> > http://personal.mail.yahoo.com/
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
> 
> 
> =====
> Rahul S. Johari (Director)
> ******************************************
> Abraxas Technologies Inc.
> Homepage : http://www.abraxastech.com
> Email : [EMAIL PROTECTED]
> Tel : 91-4546512/4522124
> *******************************************
> 
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.
> http://personal.mail.yahoo.com/
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
> 


=====
Rahul S. Johari (Director)
******************************************
Abraxas Technologies Inc.
Homepage : http://www.abraxastech.com
Email : [EMAIL PROTECTED]
Tel : 91-4546512/4522124
*******************************************

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to