Upon the case that there is a duplicate query being inserted, i would like to allow the user to select whether or not they would like to update the information specifically with a confirm() popup. The problem that i currently have is that both buttons, OK and cancel, return the result true. I realize that the variable is simply being set to the script code and thus does not retain the value. Is there a way to set the value of confirmation (or another variable) to false when the cancel button is pressed?
if (mysqli_num_rows($duplicateQueryCase1)==1){
$Confirmation = "<script> window.confirm('would you like to replace field1 with field2?');</script>";
echo $Confirmation;
if ($Confirmation == true){
$update = "UPDATE students SET phone ='$homeNumber' WHERE first_name ='$firstName' AND last_name ='$lastName' AND birthDate = '$dateOfBirth'";
mysqli_query($conn, $update);
}
else{
//echo "the element was not updated";
}
}
EDIT: As the following up above is not possible, i am looking for another solution to the if statement triggering something that allows the user (in real time as it inserts one by one) to decide whether they want to update it or not before proceeding to the next element. Any insight or suggestions would be appreciated, thanks.