I have a reservation form where once it is filled out, the rooms available for a certain building are decreased by one. I am using Cloud9 ide with php to update the record for that building in the phpmyadmin database. I think the equation to subtract one room from roomsAvailable is not being read. It might be as simple as an issue with quotes.
This is the update:
$sql = "UPDATE $dormTable SET roomsAvailable = --$dormRecord[roomsAvailable]
WHERE id = $dormRecord[id]";
"UPDATE `dorms` SET `roomsAvailable` = --5 WHERE `id` = 8"
Array ( [id] => 8 [name] => Lower West Cedar St. [class] => 2 [specialNeeds] => 1 [laundry] => 1 [fullyEquippedKitchen] => 1 [roomsAvailable] => 5 [roomsReserved] => 0 [roomCapacity] => 5 )
If you need the value of --$dormRecord[roomsAvailable] you shuold use string concatenation for $sql
In this way the php code is execute and the result is concatenated with query
$sql = "UPDATE $dormTable SET roomsAvailable = " . --$dormRecord[roomsAvailable] . " WHERE id = $dormRecord[id]";
you can see thye result using
echo $sql ;