php code
<?php
$hostname="localhost";
$username="root";
$password="tiger";
/* @var $dbhandle type */
$dbhandle = \mysqli_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
/* @var $select type */
$select= \mysqli_select_db($dbhandle,"sample")
or mysqli_error($dbhandle);
$tnumber=(\filter_input(INPUT_POST,'tnumber'));
$capacity=(\filter_input(\INPUT_POST,'capacity'));
$status=(\filter_input(\INPUT_POST,'status'));
$sql1="select * from tablecheck ";
$res=mysqli_query($dbhandle,$sql1);
$row= mysqli_fetch_array($res);
if($row['status'] === 'Booked')
{
echo "Please select another table";
}
else{
$sql="update tablecheck set status='Booked' where tnumber='$tnumber' ";
/* @var $result type */
$result= \mysqli_query($dbhandle,$sql) or die(\mysqli_error($dbhandle));
echo "success";
mysqli_close($dbhandle);
}
总是当我在文本框中输入表格编号时,即使状态未被预订,也会执行,因为请选择另一个表格,我的其他部分无效。如何克服此错误..
答案 0 :(得分:0)
首先检查您是否获得$ row [&#39; status&#39;]的值为&#34; Booked&#34;
$sql1="select * from tablecheck ";
在此声明中,您需要检查未预订状态的行,您返回的选择查询可能无法始终返回正确的结果
答案 1 :(得分:-1)
更改($row['status'] === 'Booked')
($row['status'] == 'Booked')