I have a text field which users can enter in order numbers. If they enter an order number which already exists in the DB, the information is displayed and all is well.
If, however, they enter an order number that is not in the DB, I would like to have a Javascript popup appear asking if they wish to add this new # or not.
Here a bit of the code so you can understand what I mean:
$checknum = "SELECT number FROM table WHERE number = '$number'";
$query = mysql_query($checknum);
if ( mysql_num_rows($query) >= 1 ) {
#Displays information - Working fine
}
else {
#Need a popup box here, that allows OK/Cancel. If OK, continue on somehow to inserting the new information.
}
From what I understand, javascript within PHP does not stop the PHP from completing. So, would I have to stop the code there, and then setup the javascript confirm box to pass a variable back to PHP somehow eg.
if ($yes){
$query = "INSERT INTO ...."
If that's the case, does/can anyone supply me with a small example? I've found a ton of javascript confirm boxes, but am struggling with getting it to work with PHP.
Thanks much,
B