title: Submit button on each row of a table that inserts data of that row into database
body: <p>As you can see, i have this page where there is the 'add to cart' button on each table row. Lets say i click 'add to cart' for the table row where product id is 1, i would want the productid, productname, cartquantity to be transferred to the shopping cart on another webpage. is it possible? </p>
  
  <p><a href="https://i.stack.imgur.com/TUBvL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TUBvL.png" alt="Add to cart page"></a>
  okay so as you can see i would like to add product id 1 to my cart with quantity 3. But when i pressed add to cart</p>
  
  <p><a href="https://i.stack.imgur.com/geI3V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/geI3V.png" alt="Cart Page"></a>
  It always runs to my last productid which is shofffwef and adds it to the cart instead. Not sure what is going wrong :(</p>
  
  <p>Here is my sql code for the add to cart button</p>
  
  <pre><code>if(isset($_POST['insert'])){ //$_POST[X] X = name of textbox (***You got to do this In BASHOP) take note the productname.               
      $queryinsert = "insert into cart(productid,productname,cartquantity,amount) SELECT productid,productname,'$_POST[cartquantity]', '50' FROM product WHERE productid='$_POST[hidden]'";       
             mysqli_query($dbconn,$queryinsert);                                                 
      }
  </code></pre>
  
  <p>And here is my code to show the table as in the first picture. </p>
  
  <pre><code>    while($row = mysqli_fetch_array($result)) {   
      echo "&lt;tr&gt;";
      echo "&lt;td&gt;"."&lt;input type = 'text' name='productid' value=". $row['productid'] ."&gt;&lt;/td&gt;";
      echo "&lt;td&gt;"."&lt;input type = 'text' name='productname' value=". $row['productname'] ."&gt;&lt;/td&gt;";
      echo "&lt;td&gt;" . $row['retailprice'] . "&lt;/td&gt;";
      echo "&lt;td&gt;" . $row['pointsformula'] . "&lt;/td&gt;";
      echo "&lt;td&gt;"."&lt;button type='button' class='quantityaddsub' id='sub' onclick='quantitysub(".$row['productid'].")'&gt;-&lt;/button&gt;".
                      "&lt;input type='text' class='quantity' name='cartquantity' id='quantity".$row['productid']."' value=1&gt;".
                      "&lt;button type='button' class='quantityaddsub' id='add' onclick='quantityadd(".$row['productid'].")'&gt;+&lt;/button&gt;".
      "&lt;input type='hidden' name='hidden' value=".$row['productid']."&gt;&lt;/td&gt;";
      echo "&lt;td&gt;" . "&lt;input type='submit' name='insert' value='Add To Cart'" . "&gt;&lt;/td&gt;";
      echo "&lt;/tr&gt;";
  }
  echo "&lt;/table&gt;";
  </code></pre>
  
  <p>I've searched everywhere but couldnt find a solution, please help me thanks!</p>