我正在尝试搜索酒店预订的免费房间。我在phpmyadmin中尝试了查询。它给出了结果。但是当我在mysqli_multi_query的php代码中使用它时,它无效。 multi uery返回true。但mysqli_store_result返回false而不提供任何错误消息。请帮我。在此先感谢。下面的代码
<?php
$servername="localhost";
$username="username";
$password="password";
$con= mysqli_connect($servername, $username, $password);
if(!$con)
{
die("connection failed" . mysqli_connect().error());
}
echo "connected\n ";
mysqli_select_db($con,"hotels");
$sql="create temporary table free_rooms ( `id` int not null , `rooms` int not null );
insert into free_rooms select room_id, free from rooms where free!=0;
insert into free_rooms select room_id, number from `booking` where `checkin`> '2015-11-15' or `checkout`< '2015-10-15';
select hotels.hotel_name,hotels.distance, rooms.room_type, rooms.prize, sum(free_rooms.rooms)as available from hotels, rooms, free_rooms where hotels.hotel_id= rooms.hotel_id and rooms.room_id = free_rooms.id group by free_rooms.id";
if(mysqli_multi_query($con, mysqli_real_escape_string($con, $sql)))
{
echo "\nmuliti ";\\for debugging
}
else {
echo mysqli_error ($con);
exit();
}
do{
$res= mysqli_store_result($con);
if(!$res)
echo "errorrrrr ".mysqli_error($con);\\for debugging....
else {
?>
<table width="600" border="1">
<?php
while ($row = mysqli_fetch_array($res))
{
?>
<tr><td width="300"><h3>
<?php
echo $row["hotel_name"]. "</h3>";
echo"<p>" . $row["distance"] ."</br> " .$row["room_type"] . "</br> " .$row["available"] ."</br> " .$row["prize"] ." per room</p></td>";
?>
<td width="300"><img src="" width="180" height="200" alt="Insert picture" style="background-color:#EADCAE"></td>
</tr>
<?php
}
mysqli_free_result($res);
}
if(mysqli_more_results($con)){ echo "</br>more results";}
}while(mysqli_next_result($con));
?>