Hi Guys,
I am trying to display three columns of data evenly from a database on a web page. I have it working for two columns but not sure how I can work it for three.
Each category has a different amount of rows and these should be displayed evenly on the page.
1 category = 1 in left column
2 categories = 1 in left column; 1 in middle column
3 categories = 1 in left column; 1 in middle column; 1 in right column
4 categories = 2 in left column; 1 in middle column; 1 in right column
5 categories = 2 in left column; 2 in middle column; 1 in right column
.... etc
Here is the code for two columns
//work out how to display the columns
$number_cats = mysql_num_rows($current_category);
$col_div = ceil(mysql_num_rows($current_category) / 2);
// list column 1
echo "<div class='col1'>";
$current_category_c1 = mysql_query("SELECT id, title FROM category WHERE parent_id='$id' ORDER BY id LIMIT $col_div");
while($level1 = mysql_fetch_row($current_category_c1))
// pull the data and display it
echo"</div>";
// list column 2
echo "<div class='col2'>";
$current_category_c2 = mysql_query("SELECT id, title FROM category WHERE parent_id='$id' ORDER BY id LIMIT $col_div, $number_cats");
while($level1 = mysql_fetch_row($current_category_c2))
// pull the data and display it
echo"</div>";
Any help would be great,
Thanks
Asa Carter