Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 12-21-2008, 08:00 AM data base task
Skilled Talker

Posts: 97
Trades: 0
room_type
rooms_no
persons
checkin
checkout
3 2 1 0000-00-00 0000-00-00
6 3 4 2008-11-14 0000-00-00
6 3 4 2008-11-14 0000-00-00
4 4 5 2008-11-14 2008-11-18
Now I have this table and I want to make SQL STATEMENT to make the following task
To see if the user can make a reservation in a hotel during the checkin and checkout date, by checking the numbers of rooms available in each room type during the checkin and checkout period of time
For example if the user enter number of persons that exceed the person that exists already in the database
And also to check if this period of time is available to make reservation according the the persons number

Note : rooms-type in this example are (3,6,6,4)
room_no in this example are (2,3,3,4)
person (1,4,4,5) -> number of persons
Attached Images
File Type: jpg Untitled-1.jpg (46.7 KB, 3 views)
john_zakaria is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-21-2008, 02:31 PM Re: data base task
Extreme Talker

Posts: 246
Trades: 3
Well, this seems fairly straightforward, so here is a starting point:

Assumptions:
Table is named availablerooms
Code below is for demonstration purposes and will be updated to prevent SQL injection, etc

PHP Code:
<?
//gather variables from form
$room_type $_POST["room_type"];
$persons $_POST["persons"];
$checkin $_POST["checkin"];
$checkout $_POST["checkout"];

//check if any rows in table meet criteria
$sql "
   select *
   from availablerooms
   where
      room_type = 
{$room_type}
      and persons >= 
{$persons}
      and checkin >= '
{$checkin}'
      and checkout <= '
{$checkout}'
"
;
$sql_result mysql_query($sql);
?>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
CouponGuy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to data base task
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09652 seconds with 13 queries