RE: SV: [PHP] Booking by Date/Time in mySQL

2001-03-22 Thread Jeff Armstrong

Jon, not sure if I agree with you:
  locking - almost always a bad idea, atomicity is
  much faster and safer and usually indicates a better
  relational design. SQL is fundamentally set oriented,
  but newbies are almost always row oriented.
  mySQL locks table automagically, but it doesn't do row level 
  locking, and transactions are only recently added.

  generate ids - let the db do this with ids. Almost all
  the number fountains I have seen are because of the
  inability of a 3GL to recieve the generated id efficiently,
  this is not a problem in mySQL. I do agree with you 
  though if you are refering to having a decent relational
  data model

Jeffs DB Maxims:
In my db experience 
  OS   [DOS/WIN32/Unix/Mini/Mainframe]
  Type [relational/post-relational/object/network/hierarchical]

* NEVER write SQL that requires programatic locking 
* minimise use of transactions [redesign! think lateral]
* use sql atomicity whenever possible
* don't be a pessimistic locker - optimism is so much more 
  user friendly.
* apply the twelve of codd with intelligence rather than
  obsession
* all updates should be safely repeatable
* 3NF is generally cool, but 14NF is overboard.

[soapbox.off]

Kiora

-Original Message-
From: Jon Snell [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 21, 2001 10:54 PM
To: Thomas Edison Jr.
Cc: [EMAIL PROTECTED]
Subject: RE: SV: [PHP] Booking by Date/Time in mySQL


Yes, I would recommend locking your tables before doing this just in case.
Another solution would be to create a unique-key based on the bed field and
date field.  This way you are guaranteed never to double book, and can just
check for errors after insert rather than do an additional select statement
and worry about race conditions...



-- 
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]




RE: SV: [PHP] Booking by Date/Time in mySQL

2001-03-21 Thread Jon Snell

Yes, I would recommend locking your tables before doing this just in case.
Another solution would be to create a unique-key based on the bed field and
date field.  This way you are guaranteed never to double book, and can just
check for errors after insert rather than do an additional select statement
and worry about race conditions...



-Original Message-
From: Jeff Armstrong [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 20, 2001 12:36 PM
To: Thomas Edison Jr.
Cc: [EMAIL PROTECTED]
Subject: RE: SV: [PHP] Booking by Date/Time in mySQL


the logic goes:

$start = some_start_date_a_keen_punter_entered();
$end = the_date_he_wants_to_leave();

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

if (uh_ohh_I_got_a_row_back())
  echo "Someone else is sleeping in the bed! No can do!",
   "Cheap discounts for those willing to share a bed!",
   "Are you gorgeous??";
else
  print "You got it!"
  insert good bits into database here


Of course this is not guaranteed safe, as you can end up
with double bookings in the pico seconds between the select
and the insert - but hey, how many hits a second do you expect.


Regards
Jeff's Granny


-Original Message-
From: Thomas Edison Jr. [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 20, 2001 5:08 PM
To: Jeff Armstrong
Cc: [EMAIL PROTECTED]
Subject: RE: SV: [PHP] Booking by Date/Time in mySQL


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 ...
> --
>  $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 " color=#140057>Thank you!  color=#ff>$rooms, has been booked from
> $realsdate to  color=#ff>$realedate.
> 
> ** Entries will be deleted 2 weeks after the End
> Date.
> ";
> }
>   } while ($myrow = m

RE: SV: [PHP] Booking by Date/Time in mySQL

2001-03-20 Thread Thomas Edison Jr.

Mr. Armstrong, i'm trying hard to get the message, and
i've got most of it and i'm gonna give it a whirl...

only place where i'm seeing a dizzy question mark is
this :
 if (uh_ohh_I_got_a_row_back())

right, now what exactly do i put in here that tells me
uh ohh, i got a row back The logic is neat and
pretty understandable. i'm only having problem in raw
codin. but i'm tryin. 

I think i'm gonna suff in a code and see if it works,
and i'll share the stuff with you

cheers n thanks,
T. Edison jr. 

--- Jeff Armstrong <[EMAIL PROTECTED]> wrote:
> the logic goes:
> 
> $start = some_start_date_a_keen_punter_entered();
> $end   = the_date_he_wants_to_leave();
> 
> select * from booking where
> ('$start'>=startdate and '$start'<=enddate) or
> ('$end'>=startdate and '$end'<=enddate)
> 
> if (uh_ohh_I_got_a_row_back())
>   echo "Someone else is sleeping in the bed! No can
> do!",
>"Cheap discounts for those willing to share a
> bed!",
>"Are you gorgeous??";
> else
>   print "You got it!"
>   insert good bits into database here
> 
> 
> Of course this is not guaranteed safe, as you can
> end up
> with double bookings in the pico seconds between the
> select
> and the insert - but hey, how many hits a second do
> you expect.
> 
> 
> Regards
> Jeff's Granny
> 
> 
> -Original Message-
> From: Thomas Edison Jr.
> [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, March 20, 2001 5:08 PM
> To: Jeff Armstrong
> Cc: [EMAIL PROTECTED]
> Subject: RE: SV: [PHP] Booking by Date/Time in mySQL
> 
> 
> 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 ...
> > --
> >  > $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 {
> >
> > $sq

RE: SV: [PHP] Booking by Date/Time in mySQL

2001-03-20 Thread Thomas Edison Jr.

Mr. Armstrong, i'm trying hard to get the message, and
i've got most of it and i'm gonna give it a whirl...

only place where i'm seeing a dizzy question mark is
this :
 if (uh_ohh_I_got_a_row_back())

right, now what exactly do i put in here that tells me
uh ohh, i got a row back The logic is neat and
pretty understandable. i'm only having problem in raw
codin. but i'm tryin. 

I think i'm gonna suff in a code and see if it works,
and i'll share the stuff with you

cheers n thanks,
T. Edison jr. 

--- Jeff Armstrong <[EMAIL PROTECTED]> wrote:
> the logic goes:
> 
> $start = some_start_date_a_keen_punter_entered();
> $end   = the_date_he_wants_to_leave();
> 
> select * from booking where
> ('$start'>=startdate and '$start'<=enddate) or
> ('$end'>=startdate and '$end'<=enddate)
> 
> if (uh_ohh_I_got_a_row_back())
>   echo "Someone else is sleeping in the bed! No can
> do!",
>"Cheap discounts for those willing to share a
> bed!",
>"Are you gorgeous??";
> else
>   print "You got it!"
>   insert good bits into database here
> 
> 
> Of course this is not guaranteed safe, as you can
> end up
> with double bookings in the pico seconds between the
> select
> and the insert - but hey, how many hits a second do
> you expect.
> 
> 
> Regards
> Jeff's Granny
> 
> 
> -Original Message-
> From: Thomas Edison Jr.
> [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, March 20, 2001 5:08 PM
> To: Jeff Armstrong
> Cc: [EMAIL PROTECTED]
> Subject: RE: SV: [PHP] Booking by Date/Time in mySQL
> 
> 
> 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 ...
> > --
> >  > $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 {
> >
> > $sq

RE: SV: [PHP] Booking by Date/Time in mySQL

2001-03-20 Thread Jeff Armstrong

the logic goes:

$start = some_start_date_a_keen_punter_entered();
$end = the_date_he_wants_to_leave();

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

if (uh_ohh_I_got_a_row_back())
  echo "Someone else is sleeping in the bed! No can do!",
   "Cheap discounts for those willing to share a bed!",
   "Are you gorgeous??";
else
  print "You got it!"
  insert good bits into database here


Of course this is not guaranteed safe, as you can end up
with double bookings in the pico seconds between the select
and the insert - but hey, how many hits a second do you expect.


Regards
Jeff's Granny


-Original Message-
From: Thomas Edison Jr. [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 20, 2001 5:08 PM
To: Jeff Armstrong
Cc: [EMAIL PROTECTED]
Subject: RE: SV: [PHP] Booking by Date/Time in mySQL


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 ...
> --
>  $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 " color=#140057>Thank you!  color=#ff>$rooms, has been booked from
> $realsdate to  color=#ff>$realedate.
> 
> ** 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&

RE: SV: [PHP] Booking by Date/Time in mySQL

2001-03-20 Thread Thomas Edison Jr.

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 ...
> --
>  $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 " color=#140057>Thank you!  color=#ff>$rooms, has been booked from
> $realsdate to  color=#ff>$realedate.
> 
> ** 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 PROTECT

RE: SV: [PHP] Booking by Date/Time in mySQL

2001-03-20 Thread Jeff Armstrong

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 ...
--
=$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 "Thank you! $rooms, has been booked from
$realsdate to $realedate.

** 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]




Re: SV: [PHP] Booking by Date/Time in mySQL

2001-03-20 Thread Thomas Edison Jr.

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 ... 
--
=$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','$res')";
$result = mysql_query($sql) or Die ("An unexpected
error occured. Please go back and book again.");
echo "Thank you! $rooms, has been booked from
$realsdate to $realedate.

** 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]