I'm learning PHP and getting a little frustrated. I have an html form that is sending data to another php page $_POST["id"];
.
On a 2nd php page I'm trying have the "available" column in the table either switch to 1 or 0. If it's already 1 go to 0, and if it's 0 go to 1.
I know my code is probably completely wrong and messy but please excuse me as I'm still learning.
if ($row["available"] == 1) {
//$row["available"] = 0;
$sql = "UPDATE check_in_out SET available=0 WHERE id='".$_POST["id"]."'";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
} else {
//$row["available"] = 1;
$sql = "UPDATE check_in_out SET available=1 WHERE id='".$_POST["id"]."'";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
}