[thelist] Multiple columns - howto?

CDitty mail at redhotsweeps.com
Tue Feb 18 21:24:01 CST 2003


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?

Here is the code.

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


At 07:52 PM 2/18/2003, you wrote:
>At 05:35 PM 2/18/2003, Anthony Baratta wrote:
>>pseudo code alert
>>
>>colNmbr = 1
>>colCount = 3
>>strQuery = "Select Blah Blah Blah"
>>Execute Query
>>while we have data
>>     strRow = db.DataField
>>     if colNmbr = 1 then
>>        PrintOut "<tr><td>" . strRow . "</td>"
>>        colNmbr ++
>>     else
>>        PrintOut = "<td>" . strRow . "</td>"
>>
>>     if colNmbr = colCount
>>        PrintOut = "<td>" . strRow . "</td></tr>"
>>        colNmbr = 1
>>end while




More information about the thelist mailing list