title: Use a button to pass data to a database
body: <p>I don't know if this is valid question for this site, but...</p>
  
  <p>I'm wondering how can I use buttons to add data to a database without the use of forms? I have a Table of "Products" and I want to click a button beside each product information to add that Item to an orderList in my Database. (User Cart for purchases)</p>
  
  <p>So assign a value to the button so when it's clicked it will match the unique product_id in the databse and will know what product is being selected. Thus if I click each button it will mimick a user adding a product to their cart.</p>
  
  <p>I have nine products in my database (don't mind the extra 1)... So I want to click a button so it will generate an action that will populate another table within my DB.</p>
  
  <p>Thanks</p>
  
  <pre><code>    &lt;pre&gt;
  &lt;b&gt;ID   Description         Stock Left  Price   Order ID&lt;/b&gt;
  &lt;/pre&gt;
      &lt;table align="left" border="1px" cellpadding="10" cellspacing="18" style="width: 450px;"&gt;
  
  
  &lt;?php
  $servername = "localhost";
  $username = "inserter";
  $password = "123456";
  $dbname = "pc_master_race";
  
  // Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  // Check connection
  if ($conn-&gt;connect_error) {
       die("Connection failed: " . $conn-&gt;connect_error);
  } 
  
  $sql = "SELECT product_id, product_name, current_stock, product_price FROM stock";
  $result = $conn-&gt;query($sql);
  
  if ($result-&gt;num_rows &gt; 0) {
       // output data of each row
       while($row = $result-&gt;fetch_assoc()) {
  
       echo "&lt;tr&gt;&lt;td&gt;". $row["product_id"] . "&lt;/td&gt;&lt;td&gt;". $row["product_name"] . "&lt;/td&gt;&lt;td&gt;". $row["current_stock"] . "&lt;/td&gt;&lt;td&gt;". $row["product_price"] . "&lt;/td&gt;&lt;/tr&gt;";
       }
  } else 
  {
       echo "0 results";
  }
  
  $conn-&gt;close();
  ?&gt;
  &lt;/table&gt;
  
  &lt;br&gt; &lt;input value="Order 1" type="submit"&gt;&lt;br&gt;
  &lt;br&gt; &lt;input value="Order 1" type="submit"&gt;&lt;br&gt;
  &lt;br&gt; &lt;input value="Order 2" type="submit"&gt;&lt;br&gt;
  &lt;br&gt; &lt;input value="Order 3" type="submit"&gt;&lt;br&gt;
  &lt;br&gt; &lt;input value="Order 4" type="submit"&gt;&lt;br&gt;
  &lt;br&gt; &lt;input value="Order 5" type="submit"&gt;&lt;br&gt;
  &lt;br&gt; &lt;input value="Order 6" type="submit"&gt;&lt;br&gt;
  &lt;br&gt; &lt;input value="Order 7" type="submit"&gt;&lt;br&gt;
  &lt;br&gt; &lt;input value="Order 8" type="submit"&gt;&lt;br&gt;
  &lt;br&gt; &lt;input value="Order 9" type="submit"&gt;&lt;br&gt;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/5e4uy.png" alt="Browse Page"></p>