Forum Moderators: coopster
I have a list of checkboxes like this:
<p><strong>Majors</strong></p>
<p><input type="checkbox" name="major[]" value="Engineering">Engineering</p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="5%"> </td>
<td width="95%"><input type="checkbox" name="major[]" value="Computer Science">Computer Science<br>
<input type="checkbox" name="major[]" value="Mechanical">Mechanical<br>
<input type="checkbox" name="major[]" value="Manufacturing">Manufacturing<br>
</td>
</tr>
</table>
<p><input type="checkbox" name="major[]" value="Business Administration">Business Administration<br>
<input type="checkbox" name="major[]" value="Art">Art
</p>
Notice that there is a sub group of checkboxes under Engineering and it is indented (by using a table) so that people know that it's part of Engineering. And notice that I named them as an array (major[]). Now this list will be part of a form. So people fill out the form and press submit, then a copy of what they filled out will be emailed to them. I want to use foreach() to list the checkbox values out. Something like:
foreach ($major as $value) {
print $value . '<br>';
}
But I want to keep the sub group of checkboxes under Enginerring indented, if they are selected. And I don't know how to do that. Can anyone shine some lights here on what I want to do?
I would like to name the checkboxes as an array (major[]) because my real list contains a very long list of checkboxes of major. If I named them individually, it would be very messy.
Thanks!