View Full Version : simple mysql data viewed by columns

02-22-2007, 05:07 PM
How do I make data (photos/content) output in columns?

I've posted mysql data using $rows

while($row = mysql_fetch_array($result))

This worked great when I wanted to use rows to display the data.

what I would like to do is make a simple code that would pull at the data from a Mysql DB query that would make 3 photos across and loop until all photos are displayed the DB.

I'm in a bind with this. Any help would be appreciated

02-22-2007, 07:44 PM
use a counter and the MODULUS operator (%). check the counter like this:

if (($counter % 3) == 0) {
echo "your next item here";
echo "</td></tr>"
} else {
echo "your next item here";

that would close your table cells. you will have to fiddle with your html code but the modulus example is what you need a hint on.