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.
<?php
mysql_query ("set character_set_results='utf8'");
$query= mysql_query("SELECT * FROM product");
while($row = mysql_fetch_array($query))
{
?>
<td><input readonly style=" border:none;" name="srno[]" type="text" value="<?php echo $row['srno'];?>"></td>
<td><input readonly style=" border:none;" name="pname[]" type="text" value="<?php echo $row['pname'];?>"></td>
<td> <input readonly style=" border:none;" name="price[]" id="price<?php echo $i; ?>" type="text" value="<?php echo $row['price'];?>"></td>
<td><input id="qty" name="qty[]" type="number" value="0" oninput="myFunction(<?php echo $i; ?>,this.value)" ></td>
<td>
<p id="demo<?php echo $i; ?>"><input readonly style=" border:none;" id="qty" name="total[]" type="text" value="0" oninput="myFunction(<?php echo $i; ?>,this.value)" ></p>
<?php $i++; ?>
</td>
</tr>
php coding
foreach($_POST['srno'] as $key => $n)
{
$j=1;
$n=$pname['key'];
$p=$price['key'];
$q=$qty['key'];
$t=$total['key'];
if($t>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;
}
}