title: Why does my form delete the last row rather than the selected one?
body: <p>In my code it first shows result of table and then it will delete the data upon submit. But there is issue that wherever I click in delete button I will always deleting last row. It does not delete specific row which I want to delete</p>
  
  <pre><code>$servername = "localhost";
  $username = "root";
  $password = "1234";
  $db = "ptcl";
  $con = new mysqli($servername, $username, $password, $db);
  </code></pre>
  
  <p>end connection</p>
  
  <p>html code  </p>
  
  <pre><code>  &lt;html&gt;
   &lt;body&gt;
  &lt;div class="content"&gt;
  &lt;div class="exchange"&gt;
      &lt;center&gt;EXCHANGE /NTE&lt;/center&gt;&gt;
  &lt;center&gt;
  &lt;form action="delete.php" name="delete" method="POST"&gt;
  &lt;table border="1"&gt;
  &lt;tr&gt;&lt;th rowspan="2"&gt;EXCHANGE TYPE&lt;/th&gt;
      &lt;th colspan="9"&gt;DESCRIPTION&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td colspan="2"&gt;Retail&lt;/td&gt;
      &lt;td&gt;DTEs&lt;/td&gt;
      &lt;td&gt;Retail/Sett&lt;/td&gt;
      &lt;td&gt;Online&lt;/td&gt;
      &lt;td&gt;Offline&lt;/td&gt;
      &lt;td&gt;Total&lt;/td&gt;
      &lt;td colspan="2"&gt;Action&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>form which i want to show first then delete by its id</p>
  
  <pre><code>    &lt;?php   
      global $con;
      $query="select * from exchange ";
      $result =$con-&gt;query($query);
  
      if($result-&gt;num_rows &gt; 0){
  
  
  while($row = $result-&gt;fetch_assoc()){?&gt;
  
  &lt;tr&gt;
      &lt;td&gt;&lt;?php echo $row['exchangetype']?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['retail']?&gt;&lt;td&gt;
       &lt;td &gt;&lt;?php echo $row['dte']?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $row['retail_sett']?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $row['retail']+$row['dte']+$row['retail_sett']?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $row['offine']?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $row['retail']+$row['dte']+$row['retail_sett']+$row['offine']?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="submit" name="delete" value="Delete"/&gt;&lt;/td&gt;
            &lt;td&gt;&lt;input type="hidden" name="eid" value="&lt;?php echo $row['eid']?&gt;" /&gt;  
      &lt;/td&gt;
      &lt;?php } 
      ?&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
      &lt;/center&gt;
   &lt;?php  } else{
  echo "No record found";
          }
  
     ?&gt;       
  &lt;/div&gt;
     &lt;/div&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>php delete code starts</p>
  
  <pre><code>global $con
  
  $eeid = $_POST['eid'];
  
  if (isset($_POST['delete'])) {
      $query = "DELETE FROM exchange WHERE eid='$eeid' ";
  
      if ($con-&gt;query($query) === true) {
          echo "DELETED Data";
      } else {
          echo "error during deletion" . $con-&gt;error;
      }
  }
  </code></pre>
  
  <p>It will not delete which I want to delete it delete only last row.</p>