i have my table with this columns scan_type, scan_location, and scan_wo_order so i have a scan system that insert data into my table but i see to much duplicated data so i make the error proofing to avoid that work then i see how many scan out but not scan in so i try to make a error proofing to avoid scan out without scanning IN however i can’t make that work
I TRY this but does not work
"
<?php
require "beta.con.php";
$conn = Connect();
$Scan_Type = $conn->real_escape_string($_POST["Scan_Type"]);
$Scan_Location = $conn->real_escape_string($_POST["Enter_Location"]);
$Scan_EmployeeID = $conn->real_escape_string($_POST["Enter_Employee_ID#"]);
$Scan_wo_number = $conn->real_escape_string($_POST["Scan_WO"]);
$Scan_step_number = $conn->real_escape_string($_POST["Scan_step"]);
$sql1 = "select * from wss_scans where scan_location = '".$Scan_Location."' and scan_type = '".$Scan_Type."' and scan_wo_number = '".$Scan_wo_number."'"; \\this avoid duplicate scans this one works
$sql1query = mysqli_query($conn, $sql1);
$sql2 = "select * from wss_scans where scan_location = '".$Scan_Location."' and scan_type = '".$IN."' and scan_wo_number = '".$Scan_wo_number."'";
$sql2query = mysqli_query($conn, $sql2);
$row = mysqli_num_rows($sql2query);
if(mysqli_num_rows($sql2query) < 0){
echo " Scan Work Order Number: $Scan_wo_number IN First PLEASE Check Your Submition";
}
elseif(mysqli_num_rows($sql1query) > 0){
echo " Error Work Order Already Scan $Scan_Type OR Scan Work Order Number: $Scan_wo_number IN First PLEASE Check Your Submition";
}else{
$query = "Insert Into wss_scans (scan_type, scan_location, EmployeeID, scan_wo_number, scan_step_number)
values ('" .$Scan_Type . "', '" . $Scan_Location. "', '" . $Scan_EmployeeID. "','" . $Scan_wo_number . "', '" .$Scan_step_number. "')";
$success = $conn->query($query);
if (!$success) {
die("could not entry data contact Jose or Toby: " .$conn->error);
}
else
{
echo "Data entry Successfully <br>";
}
}
$conn->close();
?>
"
the one that avoid duplicate insert work but not the one that require scan IN before scan OUT anyone have any idea how I can make that one work