My table has rows that's looped in a non-specific length because the values in the cells may be added or removed anytime. Anyway, here's the code:
<?php 
    $i = 1;
    foreach($items as $item => $itemValue) { 
    if ($itemValue['item_id'] == $parentItemValue['id']) {
        if (fmod($i,7)) echo '<tr>';
        echo '<td class="inner-td"><input type="checkbox" id="itemId">'.$itemValue['item'].'</td>';
        if (!fmod($i,7)) echo '</tr>';
        $i++;
    }
?>
I also tried if (!fmod($i,7)) echo '<tr>' and if (!fmod($i,8)) echo '</tr>' and gives me this:

Also, if (!fmod($i,10)) echo '<tr>' and if (!fmod($i,11)) echo '</tr>' and gives me this:

I want my table to look like this:

Is there a way that the cells will fill in the entire row before making a new one?

 
     
    