This is my JavaScript code:
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
for(i = 0; i < 5; i++)
{
var prikey = (i+1);
//document.getElementById("demo").innerHTML = prikey;
myFunction(xmlhttp.responseText);
}
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
function myFunction(response)
{
//some code here
}
Now, I want to transfer prikey from this JavaScript file to the server-side PHP file.
The PHP code is
$conn = mysqli_connect("$host", "$username", "$password")or die("cannot connect");
mysqli_select_db($conn,"$db_name")or die("cannot select DB");
$sql="SELECT countries FROM $tbl_name";
$result=mysqli_query($conn,$sql);
I want to integrate the transferred prikey variable such that I will be able to query the database in the following way:
$sql="SELECT countries FROM $tbl_name where id=$prikey";
where $prikey is where I store the value gotten from the JavaScript file.
How do I accomplish this?