Change the varibales $cols to be whatever number of columns you want
<?php
echo "<table border=1><tr>";
$cols = 3;
$counter = 1;
while ($row = mysql_fetch_array($sql_result)) {
$product_id = $row["product_id"];
$name = $row["name"];
$sm_img_src = $row["sm_img_src"];
if (is_int($counter / $cols)) {
print ("<td>");
print ("<center><a href=\"product_detail.php3?product_id=$product_id\"><img src=\"images/$sm_img_src\" border=\"0\"><br>$name</a></center>");
print ("</td></tr><tr>");
}
else {
print ("<td>");
print ("<center><a href=\"product_detail.php3?product_id=$product_id\"><img src=\"images/$sm_img_src\" border=\"0\"><br>$name</a></center>");
print ("</td>");
}
$counter++;
}
echo "</tr></table>";
?>