<?php include_once('dbconnect.php'); { $barcode_check = $con->query("select * from barcode where barcode='$barcode'"); if($barcode_check->rowCount() > 0) { while($row = $barcode_check->fetch(PDO::FETCH_OBJ)) { $status = $row->status; } } if($barcode_check->rowCount() > 0 && $status == 'Valid') { if($sell > 0) { echo "<script> alert('Successfully sold');</script>"; } }else if($barcode_check->rowCount() > 0 && $status == 'Invalid'){ echo "<script> alert('Item Not Sold');</script>"; }else{ echo "<script> alert('Item Not Present....');</script>"; } }else{ echo "<script> alert('Please Input or Scan Barcode.....');</script>"; } ?>