With this approach it can not be done.
Javascript
and PhP
are different things. Javascript
executes 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 similar
Delete db row according to Javascript Result
-
01-12-2021 - |
Question
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()
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow