I am trying to use nested for loops to dynamically draw a table.
I want to cap the columns at 3 or 4, but as many rows as it takes.
So far, I can limit to 3 columns, but the same variable is outputted in all three columns, then it moves on to the next..
Below is the code I am working with:
<table>
<?
/* Build Category Checkboxes */
$connCat = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$dbCat = mysql_select_db($database,$connCat)
or die("couldn't select database");
$fillCat = "SELECT * FROM cat ORDER BY cat_name";
$rsCat = mysql_query($fillCat)
or die("couldn't execute query");
while ($row = mysql_fetch_array($rsCat))
{
echo "<tr>";
for ($i = 0; $i < 3; $i++)
{
echo "<td>";
extract($row);
echo "<input type='checkbox' name='imp_cat' value='$cat_id'>$cat_name\n";
echo "</td>";
}
echo "</tr>";
}
?>