Dynamic table columns
THIS IS NOT WORKING OUT OF THE BOX
this is a small bit of code i did the other day that i found very usefull and maybe you will too ;) $catsCnt is the result from count() ing a result from mysql_fetch_array. The first line of this file is where you define how many columns you want in your table.
you need to edit this code to fit your site and maybe even just remove the part marked important
Select A Subject";
echo "\n";
echo "\n";
for($x=0; $x < $catsCnt; $x++) {
if(($x+1) % NUM_COLS == 0) {
echo "".$cats[$x]['cat_name']." |
";
if ($x!=($catsCnt-1)) echo "\n";
} else {
echo "".$cats[$x]['cat_name']." | ";
}
}
$numSpaces=$catsCnt%NUM_COLS;
if ($numSpaces!=0) {
for ($i=0;$i<=$numSpaces;$i++) {
echo " | ";
}
echo "
\n";
}
echo "\n
";
// END THE IMPORTANT STUFF
// Include the HTML footer.
include ('../includes/reg_footer.htm');
}
?>