title: how to delete the specified row from html table and also in mysql table using php
body: <p>I am currently displaying the data using a html table in <code>php</code> from <code>mysql</code> database, and i also i am allowing the user to delete only their own data from the table,my problem is how to match the delete button with the respected row,when user clicks the delete buttons only the specified row should be deleted, but it deletes all the records which is connected to the user in the database, please help me how to do this, PS i am a learner and new to <code>php</code></p>
  
  <p>UPDATED CODE GOES HERE</p>
  
  <pre><code>   &lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;View cart-d2dn&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;?php
  include('header.php'); ?&gt;
  &lt;h1&gt;View Cart&lt;/h1&gt;
  
  &lt;table border='1'&gt;
           &lt;tr&gt;
           &lt;th&gt; VIN &lt;/th&gt;
           &lt;th&gt; Vehicle Description &lt;/th&gt;
           &lt;th&gt; Price &lt;/th&gt;
           &lt;/tr&gt;
  &lt;?php
  session_start();
  $servername = "";
  $username = "";
  $password = "";
  $dbname = "";
  
  // Create connection
  $conn = mysqli_connect($servername, $username, $password, $dbname);
  // Check connection
  if (!$conn) {
      die("Connection failed: " . mysqli_connect_error());
  }
  
  
  $sql = "SELECT vin,description,price FROM products where user_id='".$_SESSION['use_i']."' ";
  $result = mysqli_query($conn, $sql);
  
  $uq=mysql_query("select * from td_user where user_id='".$_SESSION['use_i']."' ");
  $u_row=mysql_fetch_array($uq);
  if(isset($_REQUEST['delete']))
  {
  $sql_s =" DELETE FROM `products` WHERE user_id='".$u_row['user_id']."' AND vin='".$_REQUEST['vin']."' " ;
  $result_s = mysqli_query($conn,$sql_s) ;
  if($result_s == true)
  {
  echo '&lt;script language="javascript"&gt;';
  echo 'alert("Deleted successfully")';
  echo '&lt;/script&gt;';
  }
  else
  {
  echo '&lt;script language="javascript"&gt;';
  echo 'alert("Error in deletion")';
  echo '&lt;/script&gt;';
  }
  }
  if (mysqli_num_rows($result) &gt; 0) {
      while($row = mysqli_fetch_assoc($result)) {
  
      echo '&lt;tr&gt;
              &lt;td&gt;'.$row['vin'].'&lt;/td&gt;
              &lt;td&gt;'.$row['description'].'&lt;/td&gt;
              &lt;td&gt;'.$row['price'].' &lt;/td&gt;
              &lt;td&gt;  &lt;form method="post"&gt; &lt;input type="submit" name="delete" value="Delete"&gt;
   &lt;input type="hidden" name="vin" value="'.$row['vin'].'"&gt;
   &lt;/form&gt;&lt;/td&gt;
          &lt;/tr&gt;';
  
      }   
  }
  else
  {
  echo "Your cart is empty!";
  }
  ?&gt;        
  &lt;?php
  echo '&lt;/table&gt;';
  ?&gt;
  &lt;form&gt;&lt;input type="button" value="Go back" onClick="window.location.href='automobile_list.php'"&gt;
  &lt;input type="button" value="Submit" onClick="window.location.href='mail.php'"&gt;
  &lt;/form&gt;
  
  &lt;?php
  
  mysqli_close($conn);
  ?&gt;
  
  &lt;?php
  
  include('footer.php');
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>