title: How to pass multiple array variables into an html form using php
body: <p><img src="https://i.stack.imgur.com/ebeDD.png" alt="this is image of output"></p>
  
  <p>Here I pass multiple arrays into an html form tag and store the data with a single click on the submit button, but I can't get the array value to store in the database table. Please advise me on how to store these values in an array and pass them to html from the tag, and then store them in a database using php.</p>
  
  <pre><code>            &lt;?php
              mysql_query ("set character_set_results='utf8'"); 
                $query= mysql_query("SELECT * FROM product");
                while($row = mysql_fetch_array($query))
  
  
  {
  
  
              ?&gt;
                  &lt;td&gt;&lt;input readonly style=" border:none;" name="srno[]" type="text" value="&lt;?php echo $row['srno'];?&gt;"&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input readonly style=" border:none;" name="pname[]" type="text" value="&lt;?php echo $row['pname'];?&gt;"&gt;&lt;/td&gt;
  
                 &lt;td&gt; &lt;input readonly style=" border:none;" name="price[]" id="price&lt;?php echo $i; ?&gt;" type="text" value="&lt;?php echo $row['price'];?&gt;"&gt;&lt;/td&gt;
                 &lt;td&gt;&lt;input id="qty" name="qty[]" type="number" value="0" oninput="myFunction(&lt;?php echo $i; ?&gt;,this.value)" &gt;&lt;/td&gt;
                  &lt;td&gt;
  
                 &lt;p id="demo&lt;?php echo $i; ?&gt;"&gt;&lt;input readonly style=" border:none;" id="qty" name="total[]" type="text" value="0" oninput="myFunction(&lt;?php echo $i; ?&gt;,this.value)" &gt;&lt;/p&gt;
                  &lt;?php $i++; ?&gt;
                  &lt;/td&gt;
  
  
              &lt;/tr&gt;
  </code></pre>
  
  <p>
  
  <p>php coding</p>
  
  <pre><code>foreach($_POST['srno'] as $key =&gt; $n)
  {
      $j=1;
      $n=$pname['key'];
      $p=$price['key'];
      $q=$qty['key'];
      $t=$total['key'];
      if($t&gt;0)
      {
      $query = mysql_query("INSERT INTO temp
         (billno,qty,pname,price,total,user,date,village,cust_name,srno)
       VALUES ('$billno','$q','$p','$n','$t','$user',now(),'$c_name','$village','$key')")
       or die(mysql_error());
  
      $j=$J+1;
      }
  }
  </code></pre>