Good evening .. I have a form where you assign work to a worker, however, if that work is already assigned then user has a choice of either reassigning it or returning to previous page. so I'm trying to write the syntax for a confirm alert that redirects user to one page or another depending on his choice , I placed it within the head section and it goes something like this:
function show_confirm() {
var con = confirm("Already assigned.. would you like to reassign?");
if (con ==true) {
window.location = "reassign.php"
} else {
window.location = "index.php"
}
}
The question is : how do you call this function depending on an if statement? I have seen some examples on the internet where people place the function (rather than just call it ) directly inside the if statement, but wouldn't that be mixing different kinds of script? So .. how do you call the function from within this if statement? I tried this but it didnt work:
$flat=$_POST['flat'];
$check= mysql_query("SELECT * FROM assignment WHERE flat = '$flat'");
$num= mysql_num_rows($check);
if ($num!=0) { show_confirm();
} else { //irrellivant code