How can I halt a php code block when JS confirm false result. My php code like this;
<?php
function func($msg){
echo '<script type="text/javascript">
var r = confirm('$msg');
if(r==false){
return false;
}else{
return true;
}
</script>';
}
.
.
case "update":
func("Do you want to delete?");
mysql_query("UPDATE.....");
break;
?>
When func() result is false, dont process mysql_query()
With this approach it can not be done.
JavascriptandPhPare different things.Javascriptexecutes on client side end but php is server end. You would have to take into Account the power of Ajax. have a look at something similarHow to Delete MySQL Rows with Ajax & jQuery
SIMPLE JQUERY AJAX DELETE WITH CONFIRMATION