[thelist] Multiple columns - howto?

Anthony Baratta Anthony at Baratta.com
Tue Feb 18 22:55:02 CST 2003


At 07:28 PM 2/18/2003, CDitty wrote:
>Thanks Anthony.  Unfortnately, I can't get it to work.  My logic looks
>correct, but when I run the script, It total screws up the table and the
>browser craps out.  Any ideas?

Try this....

$sqlCat = mysql_query("select distinct(mainCat) FROM collectible_cats ORDER
BY mainCat asc") or die(mysql_error());
$colNum = 0;
$colCount = 3;
echo "<table cellpadding='0' cellspacing='0' align='center' border='1'>\n";
while($row = mysql_fetch_array($sqlCat)){
     $colNum++;
     if($colNum == 1){
         echo "<tr>";
     }
     echo "<td>" . $row["mainCat"] . "</td>";
     if($colNum == $colCount){
         echo "</tr>\n";
         $colNum = 0;
     }
}
if($colNum > 0 {
     while($colNum <= ($colCount-1)){
         echo "<td>&nbsp;</td>";
         if($colNum == $colCount){
             echo "</tr>\n";
         }
         $colNum ++;
     }
}
echo "</table>\n";

---
Anthony Baratta
President
Keyboard Jockeys

"Conformity is the refuge of the unimaginative."




More information about the thelist mailing list