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

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -