I am creating a carpool website and I need help with something. I have created a button and if people click on that button than the value of free spaces in the car will decrement by one(meaning the one who will click it will reserve the place). So this value must be changed in the database and also when I refresh the page it will change on the table where I display info.This is what I have written so far but doesn't seem to make a change.Thanks in advance!
<tbody>
<?php while ($row=mysqli_fetch_array($results)) {
?>
<tr>
<td><?php echo $row['username_krijim']; ?> </td>
<td><?php echo $row['nisja']; ?> </td>
<td><?php echo $row['destinacioni']; ?> </td>
<td><?php echo $row['data_krijim']; ?> </td>
<td><?php echo $row['ora_krijim']; ?> </td>
<td ><?php echo $row['vende_krijim']; ?> </td>
<td><?php echo $row['cmimi_krijim']; ?> </td>
<td><?php echo $row['mesazhi_krijim']; ?> </td>
<td><form action="index_show.php" method="POST"><input class="btn btn-primary" style="background:#f2545f;" type="submit" name="rezervo" value="Rezervo"></form></td>
<?php
if(isset($_POST['rezervo'])){
$id_krijim=$row['id_krijimi'];
$sql = "UPDATE krijo_itinerar SET vende_krijim=vende_krijim-1 WHERE id_krijimi='$id_krijim'";
mysqli_query($db, $sql);
}
?>
</tr>
<?php } ?>
</tbody>