Here is the picture of my table
Whenever I update the "Data of tools name" itself it will pop up the modal "Tools Name Existing", but when I tried to copy the existing entry for example as you can see BALLPEN is the first entry, if I edit it to BALLPEN RECHARGEABLE it should say "Tools Name Existing.
But I still made it duplicate. I don't get it what is the logical error behind this. Hope someone can help me. Thank you very much
Here is my code in PHP and with its query
<?php include('../include/connect.php'); if(isset($_POST['updateToolsBtn'])) { $id = $_POST['id']; $update_tools_name = strtoupper($_POST['tools_name']); $update_control_num = strtoupper($_POST['control_num']); $con->next_result(); $check_res = mysqli_query($con, "SELECT * FROM tools_masterlist WHERE tools_name = '$update_tools_name' AND control_no='$update_control_num'"); if(mysqli_num_rows($check_res)>0) { echo '<script> $("#tools_name_Modal").modal("show"); </script>'; } else { $query = "UPDATE tools_masterlist SET tools_name = '$update_tools_name', control_no = '$update_control_num' WHERE ID = $id"; $con->next_result(); $result = mysqli_query($con, $query); if(!$result) { echo '<script> $("#control_num_Modal").modal("show"); </script>'; } else { echo "<script> $('#update_tm_Modal').modal('show'); </script>"; } } } ?>
https://stackoverflow.com/questions/65402401/how-do-i-trap-this-kind-of-logical-error-in-query-in-php December 22, 2020 at 10:06AM
没有评论:
发表评论