the else part is not working in php -
php code
<?php $hostname="localhost"; $username="root"; $password="tiger"; /* @var $dbhandle type */ $dbhandle = \mysqli_connect($hostname, $username, $password) or die("unable connect 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 * tablecheck "; $res=mysqli_query($dbhandle,$sql1); $row= mysqli_fetch_array($res); if($row['status'] === 'booked') { echo "please select table"; } else{ $sql="update tablecheck set status='booked' tnumber='$tnumber' "; /* @var $result type */ $result= \mysqli_query($dbhandle,$sql) or die(\mysqli_error($dbhandle)); echo "success"; mysqli_close($dbhandle); }
always when enter table number in textbox,even if status not booked,it executed please select table,my else part not working.how overcome error..
first check if getting value of $row['status'] "booked"
$sql1="select * tablecheck ";
in statement need check rows status not booked, select query have returned may not return right result always
Comments
Post a Comment