4 columns category display

hey guys,
I’m trying to display list of categories pulled from the database and for some reason i cant not wrap my head round how to go about accomplishing the script. searched for the answer and for some reason I cant seem to find the write script. any help you could provide would be greatly appreciated. thanks

$catArray = categoryPull($dbcon);
$setColumn = 4;
$rowsPerCol = ceil(count($catArray) / 4); 

foreach($catArray as $key => $value)
{	if($key%$setColumn == 0) 
		echo '<div style="border:1px solid black;">';
				echo  $value['cat_category'] . '<br />';								
	if($key%$setColumn == ($setColumn - 1)) 
		echo "</div>";
}

Isn’t it will be better to use CSS for that?
You can render plain list with PHP and then arrange it in 4 columns with few style rules.

Hi Megazoid,

Thanks for the reply back. I’m using bootstrap to layout the columns so Looking to divided up the categories and list them equally among the 4 columns.

I suggest you look at the documentation to see how their grid structure is set up.

Im not looking more or less for styling but thanks for the try…

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.