title: Deleting row in a table with delete button in PHP
body: <p>I have some data coming from database and I have a delete button in last column. I want to delete the row on which delete button is clicked. But whenever I click delete button only last row is deleted even if I click on first row.</p>
  
  <p>My delete function:</p>
  
  <pre><code>if(isset($_POST['formDelete'])){
  if(isset($_POST['quoteid']) &amp;&amp; !empty($_POST['quoteid'])){
      require_once('config.php');
      $conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE) 
      or die ('Cannot connect to db');
      $quoteid = $_POST['quoteid'];
      echo "DELETE FROM quotes WHERE quoteid =".$quoteid;
      $result = $conn-&gt;query("DELETE FROM quotes WHERE quoteid =".$quoteid);
  }
  </code></pre>
  
  <p>Table code:</p>
  
  <pre><code>&lt;form action="&lt;?php $_PHP_SELF ?&gt;" method="post"&gt;
  &lt;?php
      require_once('config.php');
      $conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE) 
      or die ('Cannot connect to db');
      $result = $conn-&gt;query("SELECT quoteid, quote, cat.catid catid, cat.name cat, scat.catid catid, scat.name scat, author FROM quotes q
                             INNER JOIN category cat ON q.catid = cat.catid LEFT OUTER JOIN category scat ON q.subcatid = scat.catid order by quoteid");
      echo "&lt;table border='1px solid black'&gt;";
      echo "&lt;tr&gt;&lt;td&gt;&lt;b&gt;Category&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;Sub-Category&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;Quote&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;Author&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;";
      while ($row = $result-&gt;fetch_assoc()) {
          echo "&lt;tr&gt;&lt;td&gt;$row[cat]&lt;/td&gt;&lt;td&gt;$row[scat]&lt;/td&gt;&lt;td&gt;&lt;input type='hidden' id='quoteid' name='quoteid' value=$row[quoteid] /&gt;$row[quote]&lt;/td&gt;&lt;td&gt;$row[author]&lt;/td&gt;
          &lt;td&gt;&lt;input type='submit' name='formDelete' id='formDelete' value='Delete' /&gt;&lt;/td&gt;&lt;/tr&gt;";
      }
      echo "&lt;/table&gt;";
  ?&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I am trying to delete on the basis of quoteid.</p>