Q:

updating mysql database after an entry is deleted

Working on deleting an entry from my database table.
Currently the delete is working. However it deletes the "id + 1"
My script populates a "delete " button right next to an entry populated from mysql table.
When I hit delete next to an entry, it deletes the item +1.
I think it has to do with the while loop, the way I populate items. 
Any ideas on how to fix this?
<?php 
  while($row = mysqli_fetch_array($result)) : ?>
<tr>
  </table border = '1'><br><table border = '1'><th>Subject</th><th>Sender</th>    <th>Message</th><th>Delete</th>
  <?php 
  echo "<tr><td>";
  echo $row['subject'];
  echo "<td>";
   echo $row['sender'];
  echo "<td>";
  echo $row['msgText'];
  echo "<td>";
  ?>
    <form action="delete.php" method="post">
      <input type="hidden" name="delete_id" value="<?php  $_SESSION['id'] = $row['id'];   ?>" />
      <input type="submit" value="Delete" />
   </form>
</tr>
<?php endwhile; ?>

here is the script in delete.php
<?php
session_start();
$id = $_SESSION['id'];
$con=mysqli_connect("localhost","root","","something");
  $sql = "DELETE FROM `mailbox` WHERE `id`= '$id'";
  $result = mysqli_query($con,$sql);
   header('Location: loggedin.php');
?>

A:

<input type="hidden" name="delete_id" value="<?php  $_SESSION['id'] = $row['id'];   ?>" />

change it to:
<input type="hidden" name="delete_id" value="<?php echo $row['id']; ?>" />

and in your delete.php, simply replace $_SESSION['id'] to $_POST['delete_id']
P/S: By the way, you've forgot to add session_start(); in your form's php, if you do really want to use it, but not a good idea for this time.

