This should get you on the right path:
$iItemsPerLine = 3;
$iIndex = 0;
print "<table border=\"1\">";
while ($arrProduct = mysql_fetch_array($result))
{
if ($iIndex % $iItemsPerLine == 0)
{
if ($iIndex != 0)
{
print "</tr>\n";
}
print "<tr>\n";
}
print "<td>".$arrProduct['product_name']."</td>\n";
$iIndex++;
}
while ($iIndex % $iItemsPerLine != 0)
{
print "<td> </td>\n";
$iIndex++;
}
print "</tr>\n";
print "</table>\n";
just change $iItemsPerLine to whatever value you need, and it will work as expected.
hth
p.