title: PHP delete button always starts deleting the last row
body: <p><a href="https://i.stack.imgur.com/oDGWT.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oDGWT.jpg" alt="booklist.php on webbrowser"></a>enter image description here</p>
  
  <p><a href="https://i.stack.imgur.com/NQomf.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NQomf.jpg" alt="Database Table Contents"></a></p>
  
  <p><a href="https://i.stack.imgur.com/7q9wX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7q9wX.jpg" alt="Database Table Structure"></a></p>
  
  <p>Okay, so this may be just simple for you guys since you have experience but I can't get to figure out why is it that everytime I hit "Delete" button on the first row of my table, it deletes the last row instead of the row on which I hit "Delete." Only happens on the first row. Second row would delete just perfectly on the database. </p>
  
  <p>Is there anything wrong with my code or is there a problem with my table structure? I've provided my code for two separate php files namely booklist.php and edit.php I would appreciate your help as I am really new with PHP. Not yet familiar with all the rules and what not. Thanks.</p>
  
  <pre><code>//booklist.php below
  echo "&lt;form method='POST' action='edit.php'&gt;";
      while($row = mysql_fetch_array($result))
      {
      $bookID_Var = $row['No'];
      $titleVar = $row['Title'];
      $authorVar = $row['Author'];  //authorVar is a variable container for the value of Author row in librarydatabase
      $ISBN = $row['ISBN'];
  
      echo "&lt;tr&gt;";
          echo "&lt;td&gt;" .$bookID_Var. "&lt;/td&gt;";
          echo "&lt;td&gt;" . $titleVar. "&lt;/td&gt;";   // there's no need to quote variables. In this line, we used variables $authorVar and $titleVar
          echo "&lt;td&gt;" . $authorVar. "&lt;/td&gt;";
          echo "&lt;td&gt;" . $ISBN . "&lt;/td&gt;";
          echo "&lt;td&gt; &lt;input type='submit' value='Edit'&gt; &lt;/td&gt;"; // Edit button
          echo "&lt;td&gt; &lt;input type='submit'  name='delete' value='Delete'&gt; &lt;/td&gt;"; // Delete button
  
          echo "&lt;/tr&gt;"; 
      echo "&lt;input type='hidden' name='bookID' value='  " .$bookID_Var. "  '&gt;";
  
      } // end of while loop
  
      echo "&lt;/form&gt;";
  
  
  
  //edit.php below
  
  &lt;?php
  if (isset($_POST['delete'])) {
      echo "entered delete if block &lt;br /&gt;";
      echo "Value: " . $_REQUEST['bookID'];
  
      $bookID = $_REQUEST['bookID'];
      $sql = " DELETE FROM booklist WHERE No='$bookID'  ";
      $result = mysql_query($sql);
  
      if ($result) {
          echo "Successfully deleted" . "Book ID: " . $bookID;
      }
  } // end of main if
  ?&gt;
  </code></pre>