In html I have several buttons which are automatically made for each object in the database with a particular status. Each button gets its own id.
echo '<Button id="button'.$counter.'" onClick="clickedbutton('.$counter.', '.$row['OrderID'].')" >'."<center>".$row['OrderID']."<br>"."</center>".'</Button>';
The button calls the javascript function clickedbutton and gives it the number of the button and the orderid of that button.
function clickedbutton(buttonid,orderid){
buttonid = "button" + buttonid;
}
This function loads in the number of the button and makes it button0, button1 etc. The orderid is also succesfully passed through. Now in the function I want to call an external php script, but also orderid must be passed through to the script.
<?php
//connect to database
include_once('mysql_connect.php');
// Select database
mysql_select_db("test") or die(mysql_error());
// SQL query
$strSQL = "update orders set OrderStatus = 'In Progress' where OrderID = '" + orderid + "'";
mysql_close();
?>
I know about the mysqli protection and all, I will adjust that later. Now I want to focus on the question above, how to call and pass through the variable orderid to the phpscript.
See Question&Answers more detail:os