[eluser]jedd[/eluser]
Note that both richfearless's and BrianDHall's approaches require a ++ in there somewhere - a $count++ and a $i++ respectively.
Code:
// As an example, pilfering Brian's demonstration code
$i = 0;
echo '<tr>';
foreach ($results as $r) {
if ($i > 3) {
echo '</tr><tr>';
$i = 0;
}
echo "<td>$r</td>";
$i++;
}
echo '</tr>';
Note also - using a modulus approach means you wouldn't have to reset the $i=0 within your test on each iteration, which would reduce your code count by one line, but would be arguably be less obvious for those not familiar with that pattern .. take your pick.
EDIT: Oh, btw, what does 'random' mean in your context? I feel we may possibly have missed your intent here.