There is a closing curly brace (}) missing from your while() statement. Also you don't need the single quotes around the 3 in [minicode]
$columncount = '3';[/minicode]. Run
PHP Code:
var_dump($cats);
and throw in an echo statement into your while and see if you get any output. Also run var_dump() on $counter to see if it is changing.
Maybe check that you are getting results from the database first.