[ad_1]
I have a table and each row has unique ID so I’m trying to send this ID to another PHP page to use this ID in SQL statement. I’ve tried to do some echo statements to check if the request was successful but the echo statement wasn’t executed
Function which sends data
<script>
function promote(id) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
alert("Promoted to QA successfully");
}
};
xhttp.open("GET", "promoteAccount.php?id="+id, true);
xhttp.send();
}
</script>
promoteAccount.php
<?php
$id = $_REQUEST['id'];
require_once 'dbconnection.php';
$sql = "SELECT * FROM staf WHERE StaffID = ".$id;
$result = mysqli_query($conn, $sql);
if ($result) {
if ($row = mysqli_fetch_array($result)) {
if ($row['Role'] == "Receptionist") {
$updateSQL = "UPDATE staff SET Role="QA" WHERE StaffID = ".$id;
$updateResult = mysqli_query($conn, $updateSQL);
}
}
}
?>
[ad_2]