title: Delete MySQL row from PHP while loop
body: <p>I have a while loop displaying my database columns and rows in table. <br></p>
  
  <p>I want make a button which can delete specific MySQL row but unfortunately I can't select which of all rows have to be deleted simply because I use "while loop" to display my database content in HTML.<br></p>
  
  <p>Providing picture for better understanding what I want to do:
  <a href="https://i.stack.imgur.com/Q9WEJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q9WEJ.png" alt="enter image description here"></a>
  <br>So yeah, I want that when the green button is clicked - send MySQL query to delete this row (which is existing in my DB).</p>
  
  <p>Providing code:</p>
  
  <pre><code>&lt;?php
  //CONECT TO MYSQL
  include 'database.php';
  
  //GET VALUES
          $sql = "SELECT * FROM amountcontainer";
          $result = $conn-&gt;query($sql);
  
  
          if ($result-&gt;num_rows &gt; 0) 
          {
              //Table headlines - NOT A PHP
              echo "&lt;table class='moneytable'&gt;
                      &lt;tr&gt;
                          &lt;th style='background-color: #2d323a; color: white;'&gt;Date&lt;/th&gt;
                          &lt;th style='background-color: #2d323a; color: white;'&gt;Amount&lt;/th&gt;
                          &lt;th style='background-color: #2d323a; color: white;'&gt;Reason&lt;/th&gt;
                      &lt;/tr&gt;";
  
              // output data of each row
              while($row = $result-&gt;fetch_assoc()) 
              {
  
                  //RED //Make statement of amount red if it has a " - "
                  if(strpos($row['amount'],'-') !== false)
                  {
  
                      echo 
                      "
                          &lt;tr&gt;
                              &lt;th style='font-weight: normal;background-color: #ff9999;' class='row-time'&gt;" . $row['time'] . "&lt;/th&gt;
                              &lt;th style='font-weight: normal;background-color: #ff9999;' class='row-amount'&gt;" . $row['amount'] . "&lt;/th&gt;
                              &lt;th style='font-weight: normal;background-color: #ff9999;' class='row-reason'&gt;" . $row['reason'] . "&lt;/th&gt;
                          &lt;/tr&gt;
  
                      ";
  
                  }
  
                  //NORMAL //Make statement of amount normal if it doesn't have a " - "
                  else
                  {
                      echo 
                      "
                          &lt;tr&gt;
                              &lt;th style='font-weight: normal;' class='row-time'&gt;" . $row['time'] . "&lt;/th&gt;
                              &lt;th style='font-weight: normal;' class='row-amount'&gt;" . $row['amount'] . "&lt;/th&gt;
                              &lt;th style='font-weight: normal;' class='row-reason'&gt;" . $row['reason'] . "&lt;/th&gt;
                          &lt;/tr&gt;
  
                      ";
  
                  }
  
  
              }
              echo "&lt;/table&gt;";
          } 
  
          else 
          {
              echo "0 results";
          }
  </code></pre>