I am making a reservation system for a school project but now I got stuck.
I have a page where you can check if rooms are available for a specific room category and date
I know that you have to do a inner join. I have used google but I don't have a clue how to do it.
This is in my hotel database:
I have a rooms table:
TABLE `rooms` ( `roomNR` int(11) NOT NULL, `catagory` varchar(11) DEFAULT NULL, `picLocation` varchar(50) DEFAULT NULL, PRIMARY KEY (`roomNR`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
And I have a reservation table where all the reservations are stored.
TABLE `reservation` (
`reservationID` int(11) unsigned NOT NULL AUTO_INCREMENT,
`userID` int(11) NOT NULL,
`roomNR` int(11) NOT NULL,
`start` date NOT NULL,
`end` date NOT NULL,
`price` float NOT NULL,
PRIMARY KEY (`reservationID`),
UNIQUE KEY `userID` (`userID`),
UNIQUE KEY `roomNR` (`roomNR`),
CONSTRAINT `reservation_ibfk_1` FOREIGN KEY (`roomNR`) REFERENCES `rooms` (`roomNR`),
CONSTRAINT `reservation_ibfk_2` FOREIGN KEY (`userID`) REFERENCES `users` (`userID`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
This is the form that I use:
<form action="" method="GET">
<div>
<label for="StartDate">From</label>
<input type="input" name="startDate" id="startDate" readonly=""> <label for="EndDate">Till</label> <input readonly="" type="input" name="endDate" id="endDate">
<label for="Catagory">Catagory:</label>
<select name="Catagory" id="Catagory">
<?php
$catagorys = DB::Getinstance()->query('SELECT * FROM catagory');
if ($catagorys->count()) {
foreach($catagorys->results() as $catagory){?>
<option value="<?php echo $catagory->name; ?>"><?php echo $catagory->name; ?></option>
<?php }
}
?>
</select> <input type="submit" value="get available rooms" class="btn btn-default">
</div>
</form>
I hope some one can help me!
thank you in advance!
-- edit
Now that I'm looking at the reservation table wouldn't it be better to store also the catagory in there?