You could use the modulus operator here. Set the counter to 1, then increment after each row.
$counter = 1;
echo '<table border="0" cellpadding="0" cellspacing="0"><tr><td>';
foreach ($records as $record)
{
if($counter % 4 == 0)
echo '</tr><tr>';
echo '<a href="jewelry_item.php?jewelryID=' . $record['jewelryID'] . '">';
echo '<img src="" alt="" title="" class="first" border="0"/></a>';
echo '<a class="prod-name" href="jewelry_item.php?jewelry_id=' . $record['jewelryID'] . '">';
echo $record['jewelryName'] . "</a>";
echo '<div class="prod-price">Price: <span>';
echo $record['jewelryPrice'] . "</span></div></div>";
$counter++;
}
echo '</td></tr></table>';
You can google for modulus; however, the basic idea is that if you take the left, divide it by the right (so in our example X divided by 4), and return the remainder. We check if the remainder is 0 (i.e. X = 4, 8, 12, 16, 20, 24, 28, etc.). So 1/4 will have a remainder of 0.25, 2/4 will be 0.50, 3/4 will be 0.75 and 4 will be 0. So by checking if the remainder is 0, then you know it's been X rows.
Hope that helps.