title: How to remove a row from MySQL table data using html delete button in PHP
body: <p>I am working on a project, for school. I currently have a product page to display an assortment of item includes image, description and price etc...</p>
  
  <p>Under each product I have a delete button, when logged in as admin, which displays fine.</p>
  
  <pre><code>     if (is_admin())
          echo '&lt;a href ="#"&gt;&lt;button&gt;Delete item&lt;/button&gt;&lt;/a&gt;'; }
  </code></pre>
  
  <p>I want to know how remove the row of data from MySQL table on clicking the delete button. </p>
  
  <pre><code>&lt;?php
          // Include need php scripts
          require_once ("Includes/simplecms-config.php");
          require_once ("Includes/connectDB.php");
          include ("Includes/header.php");
  
          if (!empty($_GET['cat'])) {
              $category = $_GET['cat'];
              $query = mysqli_query($db, "SELECT * FROM products WHERE category = '".$category."'");
          } else {
              $query = mysqli_query($db, "SELECT * FROM products");
          }
  
          if (!$query) {
              die('Database query failed: ' . $query-&gt;error);
          } 
  
         $deleted = mysql_query($db, "DELETE FROM products");  
      ?&gt;
  
      &lt;section&gt;
          &lt;div id="productList"&gt;
              &lt;?php
                  $row_count = mysqli_num_rows($query);
                  if ($row_count == 0) {
                      echo '&lt;p style="color:red"&gt;There are no images uploaded for this category&lt;/p&gt;';
                  } elseif ($query) {
                      while($products = mysqli_fetch_array($query)){             
                          $file = $products['image'];
                          $product_name = $products['product'$];
                          $image_id = $products['id'];
                          $price = $products['price'];
                          $desc = $products['description'];
                          echo '&lt;div class="image_container"&gt;';
                          echo '&lt;a href="viewProduct.php?id=' . $image_id . '"&gt;&lt;p&gt;&lt;img src="Images/products/'.$file.'" alt="'.$product_name.'" height="250" /&gt;&lt;/p&gt;';
                          echo '' . $product_name ."&lt;/a&gt;&lt;br&gt;$" . $price . "&lt;br&gt;" . $desc;
  
  
                          echo '&lt;/div&gt;';
  
                              if (is_admin()){
                             echo '&lt;a href ="#"&gt;&lt;button&gt;Delete item&lt;/button&gt;&lt;/a&gt;'; 
                            }
  
                       } 
                   } else {
                       die('There was a problem with the query: ' .$query-&gt;error);             
                   } 
                   mysqli_free_result($query);     
              ?&gt;
          &lt;/div&gt;
      &lt;/section&gt;
      &lt;?php include ("Includes/footer.php"); ?&gt;
  
  
  
  &lt;!-- end snippet --&gt;
  </code></pre>