I have following PHP code contain 2 foreachs
echo "<table class='table table-bordered'>";
foreach($resultOld as $key=>$value)
{
foreach ($value as $key1 => $subjects) {
$checked = $subjects;
echo "<tr><tr class=\"".$subjects."\">$key1
<input type='checkbox' class=\"".$subjects."\" value='checked' name=\"".$key1."JAN\" $checked/> </tr>
</tr>" ;
}
}
echo "</table>";
$resultOld
is a fetchAll(PDO::FETCH_ASSOC)
output and it contains a two dimensional array. $subjects
will return 661 words from the database which means the $resultOld
array have 661 elements. And after every 12 cells I want to start a new line (tr
). That means I need 55 rows in the table. How to achieve this using PHP?