title: PHP Mysql - Delete button keeps on deleting latest row
body: <p>When i run into a glitch, I always find find the answer on StackOverflow, but this time, although I'm sure the fix is easy, I just can't seem to get it right ! </p>
  
  <p>Basically, i'm trying to add a "delete" button next to each row fetched from my mysql database. The users should be able to delete a specific post, if needed. </p>
  
  <p>When i hit the delete button, it's always the latest row  that gets deleted. So i guess there's something wrong with the value passed in each row : seems like they're overridden by the latest one.</p>
  
  <p>Below's my code:</p>
  
  <pre><code>&lt;?php  
  $table = query("SELECT post, postid FROM post_list WHERE id = ? ORDER BY 
  time DESC LIMIT 15", $_SESSION["id"]);
  foreach ($table as $row) 
  { 
        $post = $row["post"];
        $postid = $row["postid"];  
        echo ("&lt;table&gt;");
        echo ("&lt;tr&gt;");
        echo("&lt;td&gt;" . $post . "&lt;/td&gt;");
        echo("&lt;/td&gt;")?&gt;            
        &lt;div id="posteraser"&gt;
         &lt;form action='' method='post'&gt;
            &lt;input type='hidden' name='postid' value='&lt;?php echo $postid?&gt;'&gt;
            &lt;input type='submit' name='posteraser'&gt;Delete&lt;/input&gt;
         &lt;/form&gt;
        &lt;/div&gt;       
       &lt;?php 
       echo ("&lt;/td&gt;");
       echo ("&lt;/tr&gt;");
       echo ("&lt;/table&gt;");
       echo '&lt;hr&gt;';
  }  
  ?&gt;
  </code></pre>
  
  <p>And below on the same page, there's the delete button code:</p>
  
  <pre><code>&lt;?php
  if(isset($_POST['posteraser']))
  {
      $sql = query("DELETE FROM post_list WHERE postid = '$postid' ");       
      redirect ('home.php');
  }
  ?&gt;
  </code></pre>
  
  <p>Any help/tips will be much appreciated !
  Thanks a lot !</p>