-1

I want to excute mysql query in php echo clause.. please help..

mysqli_query($mysqli2,$update_book); ----> does not work.

here is my code..

$mysqli2=mysqli_connect("localhost","root","","bookDB");

$update_book="UPDATE bookinfo SET Status ='No' WHERE BookName='Step by Step'";


 echo "<script language=javascript>
   var con_test = confirm('Are you ready?');
   if(con_test == true){
     mysqli_query($mysqli2,$update_book);
     alert('Complete.');
   }
   else if(con_test == false){
     alert('Canceled.');
   }
   </script>";
Rahul
  • 18,271
  • 7
  • 41
  • 60
Yong.K
  • 11
  • 5

1 Answers1

0

You can't execute php code in a Javascript code.

You either need to use ajax (call a php file from the js code, check http://api.jquery.com/jquery.ajax/ for example), or redirect to another page when your confirm is clicked

Thelt
  • 81
  • 5