$conn=odbc_connect('keyhole_db','sa','glm101');
$sql=("SELECT * FROM tblTestProductsCategory where macrocategory like 'Men' and dept like 'Shoes'");
$columns = 3;
// check the number of rows
$num_rows = mssql_num_rows($rs);
echo "<tr><TD vAlign=top align=middle height=225>
<TABLE cellSpacing=0 cellPadding=0 width=193 border=0>";
// change this to a for loop so we can use the number of rows
for ($i = 0; $i < $num_rows; $i++) {
$row = mssql_fetch_array($sql);
if($i % $columns == 0) {
//if there is no remainder, we want to start a new row
echo "<tr>\n";
}
echo "<td>" . $rowї'Name'] . "</td>\n";
if(($i % $columns) == ($columns - 1) || ($i + 1) ==
$num_rows) {
//if there is a remainder of 1, end row or if there is nothing left in our result set, end the row
echo "</tr>\n";
}
}
echo "</table>";