View Full Version : echoing lists in two or three columns

11-10-2011, 12:16 AM
I'm hoping somebody can point me in the right direction. I have search results that display in a long-scrolling list. is there a way to have this echo into a new column of text every 20 results, for example?

For reference, here's what i have now:

echo "<td valign=top width=190>title<br><font size=1>";
while($row = mysql_fetch_array($quer4)) {
if($row[id]==@$cat){echo "<input type='checkbox' name='option1' value='$row[id]'>$row[Name] <BR>";}
else{echo "<input type='checkbox' name='option1' value='$row[id]'> $row[Name] <br>";}
echo "</font></td></tr></table>

11-10-2011, 01:18 AM
If you look at your problem sideways (figuratively :-), one option seems to really pop out.
Since tables are drawn more from the row's perspective than the column's, why don't you just make more columns by adding more <td>'s in each of your <tr>'s.

All you would need to do is decide how many columns you wanted and use a counter in your loops.

Furthermore, if you needed your result set to look like it's flowing in columns rather than rows, break it out into a nested array.

That is, unless I'm totally off here :)
Surely someone with a better resume` can shed some light on the issue.
~ Mo