Code:
<?php include("database.php"); $query2="select prodcode,prodname,id 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,MYSQL_ASSOC)) { echo"<tr>"; echo"<td>"."<input type='checkbox' id='chk' value='".$row['prodcode']."'name='checkbox1[]'/>".$row['prodcode']."</td>"; echo"<td>".$row['prodname']."</td>"; echo"<td>"."<input type='text' maxlength='4' id='quan' name='quantity[]'class ='quantity'/>"."</td>"; echo"</tr>"; } ?> <?php include("database.php"); if(isset($_POST["btnsubmit"])) { $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."' )"; mysqli_query($con,$query) or die ('Error updating database'.mysqli_error($con)); echo "</br>Record is inserted."; }
when user click on submit button checkbox values(which is checked) and textbox values should be insert into mysql table row by row.i am successful to insert multiple checkbox values but the related textbox value is not inserted into database.
how i can fix this problem??
any help plzzzzzzz??
Comment