title: How to get ID on a specific row in PHP and MySQL
body: <p>PHP is giving me error of </p>
  
  <blockquote>
    <p>Notice: Undefined index: product_id in C:\xampp\htdocs\odieinventory\admin\add_sales.php on line 6</p>
  </blockquote>
  
  <p>This is my query</p>
  
  <pre><code>&lt;?php 
    if (isset($_POST['addCart'])) {
      $product_id = $_POST['product_id'];
      $qtyBuy = $_POST['qtyBuy'];
  
      $addQuery = "INSERT INTO sales (product_id, quantity) VALUES ($product_id, $qtyBuy)";
      $execQuery = mysqli_query($connection, $addQuery);
    }
  ?&gt;
  </code></pre>
  
  <p>This is my table</p>
  
  <pre><code>&lt;form action="add_sales.php" method="POST"&gt;
          &lt;?php 
  
            $query = "SELECT * FROM products";
            $exec = mysqli_query($connection, $query);
  
            while ($row = mysqli_fetch_array($exec)) {
              $product_id = $row['product_id'];
              $product_name = $row['product_name'];
              $description = $row['description'];
              $product_quantity = $row['quantity'];
              $product_price = $row['sell_price'];
  
           ?&gt;
              &lt;tr&gt;
                  &lt;td class="text-center"&gt;&lt;?php echo $product_id; ?&gt;
                    &lt;input type="hidden" name="product_id" value="&lt;?php echo $product_id; ?&gt;"&gt;
                  &lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $product_name; ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $description; ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $product_price; ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $product_quantity; ?&gt;&lt;/td&gt;
  
                  &lt;td&gt;&lt;input type="number" min="1" max="999" name="qtyBuy"&gt;&lt;/td&gt;
              &lt;/tr&gt;
           &lt;?php } ?&gt;
  
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;/div&gt;
        &lt;div class="form-group"&gt;
  
            &lt;input type="submit" name="addCart" value="Add Items to Cart" class="btn btn-info pull-right"&gt;
  
        &lt;/div&gt;
     &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/5E65v.png" alt="My Order Page"></p>
  
  <p>I would also like to ask for advice on how to insert records on my cart. By clicking 'Add Items to Cart', I like to pass ONLY the items with values on the quantitiy input on the cart. How to achieve this with PHP?</p>