473,508 Members | 2,040 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to change the field status automatically?

17 New Member
Hi everybody. right now i'm doing a hotel reservation system using php and phpmyadmin. The process involved

1) user inputs check-in and check-out dates (to check what rooms are available during the dates input)
2) database is queried for all room categories AVAILABLE within the dates indicated

step 1 and 2 work out well using the query below :
Expand|Select|Wrap|Line Numbers
  1.  (
  2. SELECT rt.roomtypeID, rt.roomtype, rt.roomprice
  3. FROM roomtype rt
  4. INNER JOIN room r ON rt.roomtypeID = r.r_roomtypeID
  5. WHERE r.room_status = 'available'
  6. AND r.room_no NOT
  7. IN (
  8.  
  9. SELECT b_room_no
  10. FROM booking
  11. WHERE checkin >= '2010-04-04'
  12. AND checkout <= '2010-04-06'
  13. )
  14. GROUP BY rt.roomtypeID
  15.  
Then a problem arise..
How can I assign ROOM NO for any customer who has just make a reservation.

I have a 'room table' and 'roomtype table'.
right now when user make a reservation, i will assign them a random number based on the roomtype they had choose.

example : roomtype Single=10 rooms, Deluxe=10 rooms, Suite=10 rooms.

right now this is the only things that i can think right now..
Expand|Select|Wrap|Line Numbers
  1. (SELECT room_no FROM room WHERE r_roomtypeID ='single' AND room_status='available' ORDER BY RAND( ) LIMIT 1"); 
  2.  
And it did work out. But then, i was thinking, how can i automatically assign the status of"unavailable" for the room no that was just assign to the customer who had just make reservation.
So, next time if another customer wanted to make a reservation, the random number that will be selected will not involved the room that has status room_status='unavailable'.

I appreciate any ideas, keyword too google for , or any articles that i can refer to in solving this matter:)

here is my database:

Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE TABLE `booking` (
  3.   `bookingID` int(11) NOT NULL auto_increment,
  4.   `b_ic_no` varchar(30) collate latin1_general_ci NOT NULL default '',
  5.   `b_room_no` int(11) NOT NULL default '0',
  6.   `checkin` date default NULL,
  7.   `checkout` date default NULL,
  8.   `nights` int(11) default NULL,
  9.   `totalprice` int(11) default NULL,
  10.   PRIMARY KEY  (`bookingID`,`b_ic_no`,`b_room_no`)
  11. ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=7 ;
  12.  
  13. --
  14. -- Dumping data for table `booking`
  15. --
  16.  
  17. INSERT INTO `booking` (`bookingID`, `b_ic_no`, `b_room_no`, `checkin`, `checkout`, `nights`, `totalprice`) VALUES
  18. (1, '1111', 1, '2010-04-04', '2010-04-06', 2, 50),
  19. (2, '2222', 2, '2010-04-04', '2010-04-06', 2, 50),
  20. (3, '3333', 3, '2010-04-04', '2010-04-06', 2, 50),
  21. (4, '4444', 4, '2010-04-04', '2010-04-06', 2, 50),
  22. (5, '5555', 5, '2010-04-04', '2010-04-06', 2, 50),
  23. (6, '6666', 11, '2010-04-04', '2010-04-06', 2, 80);
  24.  
  25. -- --------------------------------------------------------
  26.  
  27. --
  28. -- Table structure for table `customer`
  29. --
  30.  
  31. CREATE TABLE `customer` (
  32.   `customer_id` int(10) NOT NULL auto_increment,
  33.   `username` varchar(100) collate latin1_general_ci NOT NULL,
  34.   `password` varchar(100) collate latin1_general_ci NOT NULL,
  35.   `Name` varchar(100) collate latin1_general_ci NOT NULL,
  36.   `ICNo` varchar(15) collate latin1_general_ci NOT NULL,
  37.   `DOB` varchar(15) collate latin1_general_ci NOT NULL,
  38.   `Address` varchar(100) collate latin1_general_ci NOT NULL,
  39.   `TelNo` int(15) NOT NULL,
  40.   `CompanyName` varchar(50) collate latin1_general_ci NOT NULL,
  41.   `Occupation` varchar(50) collate latin1_general_ci NOT NULL,
  42.   `Nationality` varchar(30) collate latin1_general_ci NOT NULL,
  43.   `Email` varchar(50) collate latin1_general_ci NOT NULL,
  44.   `level` int(4) NOT NULL default '2',
  45.   PRIMARY KEY  (`customer_id`,`ICNo`)
  46. ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=20 ;
  47.  
  48. --
  49. -- Dumping data for table `customer`
  50. --
  51.  
  52. INSERT INTO `customer` (`customer_id`, `username`, `password`, `Name`, `ICNo`, `DOB`, `Address`, `TelNo`, `CompanyName`, `Occupation`, `Nationality`, `Email`, `level`) VALUES
  53. (18, 'aaa', 'aaa', 'aaa', '1111', '', 'London', 1, '', 'engineer', 'chinese', 'aaa', 2),
  54. (19, 'sss', 'sss', 'sss', '2222', '', 'London', 222, '', '2222', 'chinese', '2222', 2);
  55.  
  56. -- --------------------------------------------------------
  57.  
  58. --
  59. -- Table structure for table `room`
  60. --
  61.  
  62. CREATE TABLE `room` (
  63.   `room_no` int(11) NOT NULL,
  64.   `r_roomtypeID` int(11) default NULL,
  65.   `room_status` varchar(100) collate latin1_general_ci default NULL,
  66.   PRIMARY KEY  (`room_no`),
  67.   KEY `r_roomtypeID` (`r_roomtypeID`)
  68. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
  69.  
  70. --
  71. -- Dumping data for table `room`
  72. --
  73.  
  74. INSERT INTO `room` (`room_no`, `r_roomtypeID`, `room_status`) VALUES
  75. (1, 1, 'unavailable'),
  76. (2, 1, 'unavailable'),
  77. (3, 1, 'unavailable'),
  78. (4, 1, 'unavailable'),
  79. (5, 1, 'unavailable'),
  80. (6, 1, 'available'),
  81. (7, 1, 'available'),
  82. (8, 1, 'available'),
  83. (9, 1, 'available'),
  84. (10, 1, 'available'),
  85. (11, 2, 'unavailable'),
  86. (12, 2, 'available'),
  87. (13, 2, 'available'),
  88. (14, 2, 'available'),
  89. (15, 2, 'available'),
  90. (16, 2, 'available'),
  91. (17, 2, 'available'),
  92. (18, 2, 'available'),
  93. (19, 2, 'available'),
  94. (20, 2, 'available'),
  95. (21, 3, 'available'),
  96. (22, 3, 'available'),
  97. (23, 3, 'available'),
  98. (24, NULL, NULL);
  99.  
  100. -- --------------------------------------------------------
  101.  
  102. --
  103. -- Table structure for table `roomtype`
  104. --
  105.  
  106. CREATE TABLE `roomtype` (
  107.   `roomtypeID` int(11) NOT NULL auto_increment,
  108.   `roomtype` varchar(30) collate latin1_general_ci default NULL,
  109.   `roomprice` int(11) default NULL,
  110.   PRIMARY KEY  (`roomtypeID`)
  111. ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=6 ;
  112.  
  113. --
  114. -- Dumping data for table `roomtype`
  115. --
  116.  
  117. INSERT INTO `roomtype` (`roomtypeID`, `roomtype`, `roomprice`) VALUES
  118. (1, 'single', 50),
  119. (2, 'Twin Sharing', 80),
  120. (3, 'Deluxe', 100),
  121. (4, 'Superior', 130),
  122. (5, 'Suite', 150);
  123.  
  124.  
Apr 3 '10 #1
0 1476

Sign in to post your reply or Sign up for a free account.

Similar topics

34
4873
by: Andrew DeFaria | last post by:
I thought this would be fairly straight forward but apparently it's not. Given the following html file: <!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en"> <html> <head>...
0
2143
by: Just D | last post by:
Hi All, Does anybody know how to write the following code? I have a database table with a few columns including: ID , "Task" , ForceRun . I need to show the DataGrid on the ASPX page with...
3
1987
by: Melon via AccessMonster.com | last post by:
If anyone could take a look at this, I could do with the help. Im running into 2 problems with my db. 1) I have a members section in my db. If a member is selected as senior, all fields apply...
3
4186
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - I have window.status="Moomin"; why doesn't the statusbar change?...
5
2958
by: Rex | last post by:
Hi, I want to change a value in one table depending on the value(s) in another table. I am trying to achieve this in a form. to elaborate I have a many-to-many relationship between tables...
2
2920
by: aldeb | last post by:
My dilemma is as follows. I have a continous form that I am using as a Visual Display Form to show the status of records (SoeCodes). What their status currently is and what they have been. I have 6...
0
2186
by: morathm | last post by:
I have a windows client database management application written in C# that connects to remote web services to do all the heavy work. The thin-client app uses strong typed datasets, all maintained at...
8
8465
by: P00HB33R | last post by:
Hi there ppl, I hope you guys can help me. I have two fields: and . I've set the POD status' default value as "Awaiting". There are only 2 possible values: "Awaiting" and "Recieved". What I'd...
0
7226
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7049
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5055
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.