RE: I could really use your help with it(making reservations to hotels etc)(MY SOLUTION)
| From: | Siim Einfeldt aka Itpunk | Date: | Fri, 29 Dec 2000 16:14:39 +0000 |
| Subject: | RE: I could really use your help with it(making reservations to hotels etc)(MY SOLUTION) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-32184@lists.php.net to get a copy of this message | ||
Hey again,
I`ve now thougth about it a bit and I think the best solution for me
would be to separate all the time periods, eg, if I had 2000-12-12 -
2000-12-14 in the table, I jsut write the whole thing into another table
into separate rows, eg:
2000-12-12
2000-12-13
2000-12-14
The code that I made for rewriting the 'dates' table, is the
following. Right now itú untested as first I need to get the data out of
excel into mysql and then I can make the little conversion. But if you
have any suggestions about it, I`d like to hear it.
The code:
$days_statement = mysql_query("SELECT
TO_DAYS(firstdate) dateone,TO_DAYS(lastdate) datetwo FROM tabel");
while ($getdays = mysql_fetch_array($days_statement)){
$day_statement = mysql_query("SELECT
TODAYS('".$getdays["dateone"]."')
one,TODAYS('".$datetwo."') two");
$getdays = mysql_fetch_array($day_statement);
$days1 = $getdays["one"];
$days2 = $getdays["two"];
for ($i=$days1;$i<=$days2;$i++){
$date_statement = mysql_query("SELECT
FROM_DAYS('$i') day");
$getdate =
mysql_fetch_array($date_statement);
mysql_query("INSERT INTO othertable
(datecol) VALUES ('".$getdate["day"]."')");
}
}
Cheers
Siim Einfeldt
> From: Siim Einfeldt aka Itpunk [mailto:siim_e@pshg.edu.ee]
> Sent: Wednesday, December 27, 2000 1:25 PM
> To: mysql@lists.mysql.com; php-general@lists.php.net
> Subject: I could really use your help with it(making reservations to
> hotels etc)
>
>
> I need some help with making reservations to a hotel. I have the following
> information in the database:
>
> (1) hotel name
> (2) room type
> (3) number of places within some days
> (4) the first date
> (5) the last second date
>
> The first and the last date represent the time for which the travel agency
> has made their reservations to some hotel and the number represents the
> number of rooms reserved for this period of time.
>
> That was now the back-end stuff... Now, when customer comes to their
> website, he/she chooses a hotel, room type and then he also types in the
> dates, when he would like to stay there (I have dropdowns for that).
>
> OK, that was the story. What I would like to know is, what would be the
> best way to get to know if there will be free rooms. The travelling agency
> has made different reservations in hotels usually for 1-2 days,eg:
>
> Time period: 24.01.2001 - 26.01.2001 Number of rooms: 10
> Time period 26.01.2001 - 27.01.2001 Number of rooms: 3
>
> Lets imagine that now comes the customer, types in the time period
> 25.01.2001 - 27.01.2001, it covers one one period fully and another only
> partly. damn...sorry, I even don`t know what I need from you exactly, I
> guess I`d like to know
>
> -->how could I check if there was free rooms for the full period of time
> that the customer has entered AND -->how to write to the database, that
> one room from that period and one room from half of the other period has
> been reserved?
>
> I don`t know, maybe it seems simple, but...by now my brain is dead. If
> someone could help me, I would really appreciate it, maybe if someone has
> done some site for some travelling agency himself, you could get in touch
> and explain this thing a bit.
>
> braindead...
> Siim Einfeldt
> itpunk@itpunk.com
>
>
>
>
> --
> ---------------------------------------------------------------------
> Please check
> "http://www.mysql.com/documentation/manual.php" before
> posting. To request this thread, e-mail mysql-thread60038@lists.mysql.com
>
> To unsubscribe, send a message to:
> <mysql-unsubscribe-mordron=aoj.net@lists.mysql.com>
>
> If you have a broken mail client that cannot send a message to
> the above address (Microsoft Outlook), you can use:
> http://lists.mysql.com/php/unsubscribe.php
>
>