I cannot find out what's wrong in this code. Since the query executes and insert also works but the error msg shows:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\kurinchi\kkmalar.php on line 41
$q = intval($_GET['q']);
$availability = isset($_GET['availability']);
$con = mysqli_connect('localhost','root','','kurinchi');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con,"ajax_demo");
$sql="UPDATE rooms SET availability=(availability-1) WHERE ID = (SELECT ID from (SELECT * from rooms WHERE ID = '".$q."')AS innerResult)" ;
$result = mysqli_query($con,$sql);
if($result === FALSE) {
die(mysql_error());
}
echo "<table>
<tr>
<th>ROOM TYPE</th>
<th>AC TYPE</th>
<th>PRICE</th>
<th>AVAILABILITY</th>
<th>BOOK </th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['room_type'] . "</td>";
echo "<td>" . $row['ac_type'] . "</td>";
echo "<td>" . $row['price'] . "</td>";
echo "<td>" . $row['availability'] . "</td>";
echo "<td>" . $row['booking_status'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);