我正在制作一个酒店数据库,并写了一个查询,该查询应打印出某段时间内所有可用的房间,但是当我运行它时,它不打印任何东西。它使用表格预订和房间的信息。这是php代码,以及html代码。有人可以告诉我这里我做错了吗?
<HTML>
<head> </head>
<body>
<h3>Choose the period to see which are the free rooms:</h3>
<form action="query2.php" method ="GET"><br>
<fieldset>
<div class="field">
<div class="pick-date">
<label for="date_from"></label>
From: <input type="date" name="a">
<br/><br/>
<div class="field">
<label for="date_to">
To: <input type="date" name="b">
</label>
</div> <br/>
<div class="field">
<label for="room_type">
Room type:
<select name="room type[]">
<option></option>
<option>Classic single</option>
<option>Superior single</option>
<option>Classic double</option>
<option>Superior double</option>
<option>Vip room</option>
<option>Family room</option>
</select>
<br/><br/>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
<?php
$x = isset($_GET['room type[]']);
if (!isset($_GET['a']))
{$a = null; }
elseif (!is_string($_GET['a'])) {
$a = false;
} else { $a = $_GET['a'];
}
$b = isset($_GET['b']) && is_string($_GET['b']) ? $_GET['b'] :'';
$query=mysql_query(
"select r_id, r_type, r_price
from Rooms
WHERE r_type='$x' and r_id not in
(select b_rooms
from booking
where (b_checkin >= '$a' and b_checkin < '$b')
or (b_checkout >= '$a' and b_checkout < '$b'));" );
if (!$query) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($query))
{
echo $row['r_type'];
echo" ";
echo $row['r_price'];
echo" ";
echo $row['r_id'];
echo"<br>";}
mysql_free_result($query);
?>