here i am having a form like this .i am having multiple checkboxes that are coming from database and i have given a field with every checkbox...now suppose 10 checkboxes are coming from database..now i want to insert values in database only of those checkboxes which are checked along with their textbox values..here is my php script.when i click on submit button the checkbox values are getting inserted right but the textbox values are not getting inserted... can anyone help me with the code ??
<?php
include("database.php");
$query2="select prodcode,prodname from product";
$result2=mysqli_query($con,$query2);
echo"<table border='2' align='center' cellpadding='0' cellspacing='0' style='width:50%'>";
echo"<tr>";
echo"<thead>";
echo"<th>"."ProductCode"."</th>";
echo"<th>"."ProductName"."</th>";
echo"<th>"."Quantity"."</th>";
echo"</thead>";
while($row=mysqli_fetch_array($result2))
{
echo"<tr>";
echo"<td>"."<input type='checkbox' id='checkbox1[]' value='".$row['prodcode']."' name='checkbox1[]'/>".$row['prodcode']."</td>";
echo"<td>".$row['prodname']."</td>";
echo"<td>"."<input type='textbox' maxlength='4' id='quan' name='quantity[]' class ='quantity' />"."</td>";
echo"</tr>";
}
?> <tr> <td colspan="4" align="center"><input class="submit" type="submit"
name="btnsubmit" value="Submit" onclick=" return validate();"/></td></tr> <?php
include("database.php");
$check=$_POST['checkbox1'];
$quantity=$_POST["quantity"];
for ($i=0; $i<sizeof($check);$i++)
{
$query="INSERT INTO elevconfigdetails (id,prodcode,quantity)
VALUES ('$id','".$check[$i]."','".$quantity[$i]."' )";
mysqli_query($con,$query) or die ('Error updating database'.mysqli_error($con));
echo "</br>Record is inserted.";
}