i m new to php and coding is old school
<?php
for($i=-2; $i<count($s2)-1;$i++){ ?>
<tr>
<td>
<?php
switch ($i) {
case '-2':
echo "JR KG";
goto a;
break;
case '-1':
echo "SR KG";
break;
case '0':
echo "Nursery";
break;
default:
echo $i;
?>
</td>
<?php foreach($a2 as $aaa){ a: ?>
<td>
<input type="checkbox" name="<?php echo $aaa.'['.$i.']'; ?>" >
</td>
<?php
}
?>
</tr>
<?php
}
}
?>
by above code i wanted to display list of standard and display a checkbox for each division (a-h). after printing standard i want to display the grid like checkboxs. this works for i= 1 to 12.. fails for -2,-1,0 because of break();
so i tried adding a goto a; but getting following error
Fatal error: 'goto' into loop or switch statement is disallowed in
any suggestions how to get the checkboxes for each division for the 1st three fields.
with the loop of "i" i am starting a row that display standard, and with the loop of "foreach($a2)" i am want to append number of checkboxes foreach divison in $a2.. want to create like a grid. its failing to append the checkboxes in first 3 rows because of break()
thanks.
I am still no totally sure I understand.
But if you want to do something different in the three special cases try this general idea.
<?php
function add_checkboxes($i, $a2) {
// do the checkbox processing in here
if ( $i == -2 ) {
foreach($a2 as $aaa){ a: ?>
echo '<td>';
echo '<input type="checkbox" name="' . $aaa . '['.$i.'] .'" >';
echo '</td>';
}
}
}
for($i=-2; $i<count($s2)-1;$i++){
?>
<tr>
<td>
<?php
switch ($i) {
case '-2':
echo "JR KG";
add_checkboxes($i, $a2);
break;
case '-1':
echo "SR KG";
add_checkboxes($i, $a2);
break;
case '0':
echo "Nursery";
add_checkboxes($i, $a2);
break;
default:
echo $i;
?>
</td>
</tr>
<?php
}
}
?>