Same thing using PHP
<?php
const HOST = '????';
const USERNAME = '????';
const PASSWORD = '????';
const DBNAME = '????';
$staffno = 3;
$appno = 4;
mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); // Tell mysql to report errors
$conn = mysqli_connect(HOST,USERNAME,PASSWORD,DBNAME); // connect to DB
$conn->set_charset('utf8');
ShowData($conn);
$stmt = $conn->prepare("UPDATE test_91
SET staffno = ?
WHERE appno = ?
");
$stmt->bind_param('ii', $staffno, $appno);
$stmt->execute();
echo "<br><b>Table updated here</b><br>";
ShowData($conn);
function ShowData($conn)
{
$res = $conn->query("SELECT * FROM test_91");
echo '<pre>';
printf("%-10s%-10s%-10s<br><br>", 'AppID', 'AppNo', 'StaffNo');
foreach ($res as $row) {
vprintf("%-10s%-10s%-10s<br>", $row);
}
echo "</pre>\n";
}
?>
Output...
AppID AppNo StaffNo
1 2 2
2 3 2
3 4 0
4 4 0
5 4 0
6 4 0
Table updated here
AppID AppNo StaffNo
1 2 2
2 3 2
3 4 3
4 4 3
5 4 3
6 4 3