title: How to send variables from a loop using javascript or jquery post method and receive using php
body: <p>I want display all table values and then send and receive them on another php page using javascript post menthod but it seems my code is only able to send one item from the table list to another php page.</p>
  
  <pre><code>&lt;form  class="commerce" id='commence'&gt;
      &lt;input type='text' id='shop' value='' class='form-wrapper'&gt;
      &lt;?php
      $check = "SELECT * FROM tbl_products ";
      $checks = mysqli_query($db, $check);
      while ($found = mysqli_fetch_array($checks)) {
  
          $id = $found['id'];
          $amount = $found['amount'];
          $price = $found['price'];
          echo"&lt;input type='text' id='product' value='$id' class='form-wrapper'&gt;
              &lt;input type='text' id='stock' value='$amount' class='form-wrapper'&gt;
              &lt;input type='text' id='price' value='$price' class='form-wrapper'&gt;";
      }
      ?&gt;
      &lt;button type='button' class='prisoner_entry '  &gt;SAVE&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      $(document).on("click", ".prisoner_entry", function () {
          var fname = document.getElementById("shop").value;
          var product = document.getElementById("product").value;
          var stock = document.getElementById("stock").value;
          var price = document.getElementById("price").value;
          $.ajax({
              type: 'POST',
              url: "data.php",
              data: {
                  fullname: fname, productname: product, stocknumber: stock, itemprice: price},
              success: function (result) {
              }
          });
  
      });
  &lt;/script&gt;
  </code></pre>
  
  <pre><code>&lt;?php
  if(isset($_POST['fullname'])){
  
                $fullname = mysqli_real_escape_string($db,$_POST["fullname"]);      
                $productname = mysqli_real_escape_string($db,$_POST["productname"]);  
                $stocknumber =mysqli_real_escape_string($db,$_POST["stocknumber"]);       
                $itemprice =mysqli_real_escape_string($db,$_POST["itemprice"]);      
                $rphone = mysqli_real_escape_string($db,$_POST["rephone"]);     
                  }   
  ?&gt;
  </code></pre>