I'm making a project on Hotel Management using wamp server. In this I have to check the availability of a room and display it as available or not depending upon the Room Type. I have connected php to my mysql database. Now the problem is that I am accepting the room type from user and storing it in '$Room' and when I take "Room='$Room'"(where 'Room' is an attribute of the Table in my msql database) in my mysqli query it says that the value can't be of boolean (at line mysqli_fetch_row), but when I pass a value such as "Suites" it shows no error when I run it.
I have tried to do it without the mysqli_fetch_row and directly passed it in the if statement, but in that case it says that "Object of class mysqli_result could not be converted to int".
<?php
if(isset($_POST['room']))
{
$Room=$_POST['Room'];
$re1=mysqli_query($a,"select Available from availability where Room='$Room");
$row1=mysqli_fetch_row($re1);
$res1=$row1[0];
if($res1<1)
{
echo "Unavailable";
}
else
{
echo "Available";
}
}
?>
I want to be able to accept the value from the user and compare it in the if statement and if the value is less than 1 then it should say "Unvailable" else "Available".
Aucun commentaire:
Enregistrer un commentaire