When being saved to database, it iterates like this The foreach ($ac) keeps on iterating based on the clicked checkboxes, can somebody help me please this is for my project. I think there is sonething wrong with my logic on the foreach but i dont know where it is exacty. Please debug this anyone. :))))))))))))))))))))))))))))))
<html>
<body>
<div class="image">
<img src="PLM1.png" alt="plmbackground" height="650" width="1351"/>
</div><br><br><br><br>
<form method = "post" class="content">
<font size= '5px'>Student ID <input type="text" name = "student_id"> <br>
OR NO <input type = "text" name = "or_no"> <br>
</font>
<table align="center">
<tr valign="middle" align="center">
<td><font color="red"><b>REQUESTS</b></font>
<td><font color="red"><b>QUANTITY</b></font>
</tr>
<tr>
<td><input type = "checkbox"name = "ac_description[]" value = "Replacement_of_Registration"><b>Replacement of Registration</b>
<td><center><input type="number" name="quantity[]" style="width:60px;"></center>
</tr>
<tr>
<td><input type = "checkbox"name = "ac_description[]" value = "Good Moral Certificate"><b>Good Moral Certificate</b>
<td><center><input type="number" name="quantity[]" style="width:60px;"></center>
</tr>
</tr>
<tr>
<td><input type = "checkbox" name = "ac_description[]" value = "Honorable Dismissal "><b>Honorable Dismissal</b>
<td><center><input type="number" name="quantity[]" style="width:60px;"></center>
</tr>
</tr>
<tr>
<td><input type = "checkbox" name = "ac_description[]" value = "Transcript of Record"><b>Transcript of Record</b>
<td><center><input type="number" name="quantity[]" style="width:60px;"></center>
</tr>
<tr>
<td><input type = "checkbox" name = "ac_description[]" value = "Diploma"><b>Diploma</b>
<td><center><input type="number" name="quantity[]" style="width:60px;"></center>
</tr>
<tr>
<td><input type = "checkbox" name = "ac_description[]" value = "CUE Request"><b>CUE Request</b>
<td><center><input type="number" name="quantity[]" style="width:60px;"></center>
</tr>
<tr>
<td><input type = "checkbox" name = "ac_description[]" value = "CMI Request"><b>CMI Request</b>
<td><center><input type="number" name="quantity[]" style="width:60px;"></center>
</tr>
<tr>
<td><input type = "checkbox" name = "ac_description[]" value = "Entrance Exam"><b>Entrance Exam</b>
<td><center><input type="number" name="quantity[]" style="width:60px;"></center>
</tr>
<tr>
<td><input type = "checkbox" name = "ac_description[]" value = "School fees-Medical/Dental Laboratory "><b>School fees-Medical/Dental Laboratory</b>
<td><center><input type="number" name="quantity[]" style="width:60px;"></center>
</tr>
<tr>
<td><input type = "checkbox" name = "ac_description[]" value = "School fees-Transcript/Honorable"><b>School fees-Transcript/Honorable</b>
<td><center><input type="number" name="quantity[]" style="width:60px;"></center>
</tr>
<tr>
<td><input type = "checkbox" name = "ac_description[]" value = "School fees-Library"><b>School fees-Library</b>
<td><center><input type="number" name="quantity[]" style="width:60px;"></center>
</tr>
<tr>
<td><input type = "checkbox" name = "ac_description[]" value = "Affiliation Fees"><b>Affiliation Fees</b>
<td><center><input type="number" name="quantity[]" style="width:60px;"></center>
</tr>
</table>
<br>
<input type = "submit" name = "send" value = "Add" class="btn-5" >
</form>
<?php
//the database connection
$db = mysqli_connect ("localhost", "root", "turtledove", "accounting");
if (!$db)
{
die ("ERROR!!!!!!>>>");
}
$student_id = $_POST["student_id"];
$or_no = $_POST["or_no"];
$status1="processing";
$qty=1;
$col_credit = 80;
$dep_credit = 80;
$col_debit = 0;
$dep_debit = 0;
$quantity = $_POST["quantity"];
$ac_description = $_POST["ac_description"];
if (($quantity)&&($ac_description) )
{
foreach ($quantity as $quantity)
{
foreach ($ac_description as $ac)
{
mysqli_query($db, "insert into or_header (or_no, ac_description, student_id, date1, status1, qty,
col_credit, col_debit, dep_credit, dep_debit)
values (".$or_no.",'".mysqli_real_escape_string($db,$ac)."',
'".$student_id."',curdate(),'processing',".$quantity.",80,0,80,0)");
}
}
}
?>
<form action="cashiermainpage.php">
<input type="submit" method="POST" value="Mainpage" class="mainpage" alt="Submit">
</form>
</body>
</html>