PHP Code:
$cats mysql_query("SELECT * FROM categories"); 
while(
$showCats mysql_fetch_array($cats)) { 
$category $showCats['catid']; 
$subq "SELECT * FROM categories WHERE catid = '$category' "
$sub mysql_query($subq); 
if(!
mysql_num_rows($sub)) die("Error. Your query was $subq <br> and the error was ".mysql_error()); 
echo 
"<tr><td class=\"tablea\" style=\"border-style: none; border-width: medium\" height=\"10\">&nbsp;<b>".$showCats['catname']."</b></td><td class=\"tablea\" style=\"border-style: none; border-width: medium\" height=\"10\"></td></tr>";
while(
$showSub mysql_fetch_array($sub)) {  
echo 
"<tr><td class=\"tablea\" style=\"border-style: none; border-width: medium\" height=\"10\">&nbsp;<a style=\"font-size: 11px; font-family: tahoma, sans-serif; text-decoration: none; background: none\" href=\"index.php?cat=".$showSub['name']."\"><font size=\"2\">".$showSub['name']."</font></a></td><td class=\"tablea\" style=\"border-style: none; border-width: medium\" height=\"10\"><b>".$cat['count_movies']."</b></td></tr>";
}} 

Its was echo double information (if 2 subs, print double categories) like

Code:
Category1
- sub1
- sub2
Category1
- sub1
- sub2
Category2
- sub1
- sub2
- sub3
Category2
- sub1
- sub2
- sub3
Category2
- sub1
- sub2
- sub3