Forum Moderators: coopster
I am having problems with checkboxes.
I have there rows of checkboxes and each row has seven checkboxes.
while($count < 3)
{
echo '<table cellpadding=0 cellspacing=0><tr><td>';
echo '<input type=checkbox name=check_sun STYLE="font-size:10px;" value=1> </font></td>';
echo'<td width=20>
<input type=checkbox name="check_mon[]" STYLE="font-size:10px;" value=2></td>';
echo'<td width=20>
<input type=checkbox name="check_tues[]" STYLE="font-size:10px;" value=3></td>';
echo'<td width=20>
<input type=checkbox name="check_wed[]" STYLE="font-size:10px;" value=4></td>';
echo'<td width=20>
<input type=checkbox name="check_thurs[]" STYLE="font-size:10px;" value=5></td>';
echo'<td width=20>
<input type=checkbox name="check_fri[]" STYLE="font-size:10px;" value=6></td>';
echo'<td width=20>
<input type=checkbox name="check_sat[]" STYLE="font-size:10px;" value=7></td>';
echo'</tr>';
echo '</tr>';
echo '<tr>';
echo '<td><br></td>';
echo '</tr></table>';
$count++;
}
What I want to do is record the values for checked and unchecked checkbox for each row. For example, if in the first row of checkboxex, only the the first three checkboxes are checked the database will record "1" for those first three checkboxes and record "0" for the last four checkboxes. I want to do this for every row of checkboxes. However, when I do, the database is not record the correct checked checkbox for each row. For example, if I checked the first three checkboxes on the first and leave the rest of the checkboxes in the first row unchecked and then checked the the last four checkboxes in the second row, the database would record "1" for the first row of checkboxes, which is not true.
"1"= true for checked checkbox
"0"= not checked checkbox
Rows and columns of CheckBoxes that are checked
-------------------------------------
1 1 1 0 0 0 0
--------------
0 0 0 1 1 1 1
--------------
0 0 0 0 0 0 0
The result in the database would be:
---------------
1 1 1 1 1 1 1
---------------
0 0 0 0 0 0 0
---------------
0 0 0 0 0 0 0
when the correct insertation in the database should be:
---------------
1 1 1 0 0 0 0
---------------
0 0 0 1 1 1 1
---------------
0 0 0 0 0 0 0
Can someone help? I hope I was clear on my problem.
Thanks,
Fib_81
I think you told me that before. Sorry for having you repeat the instructions all over again. So...I cannot assign the first sunday checkbox in the first row and the second sunday in the second row as sunday[0] and sunday[1] with respect. I only can do that if both first and second sunday is checked? Thanks for your patience.
Regards,
Fib_81
<input type=checkbox name="check_mon_1" STYLE="font-size:10px;" value=1>
<input type=checkbox name="check_mon_2" STYLE="font-size:10px;" value=1>
<input type=checkbox name="check_mon_3" STYLE="font-size:10px;" value=1>
Then your PHP:
$num_checkboxes = 3;
for ($i = 1; $i <= $num_checkboxes; $i++)
{
if (isset($_POST['check_mon_' . $i]))
{
// Apply action here
}
}
Hope that makes sense