I want to know if it possible to pass a value from database as seen below into my php file and UPDATE the corresponding row value based on this passed paramater. For example, When user clicks the button, this will update value inside database based on the id of where the button is located. Thank you.
<?php
// Selecting Database
include_once 'dbh.php';
//Here we fetch the data from the URL that was passed from our HTML form
$userEmail = $_POST['userEmail'];
$jobiD = $_POST['jobID'];
$sql = "UPDATE jobPost SET emailTeacher='$userEmail' WHERE jobID= ('".$jobID."');";
mysqli_query($conn, $sql);
?>
AJAX -
function myFunctionjobStatus() {
var jobID = document.getElementById("jobID").value;
//AJAX code to submit form.
$.ajax({
type: "POST",
url: "http://localhost:8888/EduSubOct/jobstatus.php",
data: { userEmail: localStorage.getItem("email"), 'jobID':
jobID },
cache: false,
success: function(html) {
alert("Request Sent");
}
});
}
PHP variables are case-sensitive you know?
$jobiD = $_POST['jobID'];
$jobiD should be $jobID as you used it on your query string:
$sql = "UPDATE jobPost SET emailTeacher='$userEmail' WHERE jobID= ('".$jobID."');";