the following should work but no guarantees...
change $num_cols as needed to 3, 4, 5, etc
Code:
<?php
include("application.php");
// ---------------
// functions
// ---------------
function ShowMainPage() {
global $template_path,$number_of_links;
global $category;
global $cat_table_width,$cat_cellspacing,$cat_font_face,
$cat_font_size,$cat_link_style,$subcat_font_face,
$subcat_font_size,$subcat_link_style;
// ----- display categories in 2 columns -----
$category = "<table width=$cat_table_width cellspacing=$cat_cellspacing>";
$category .= "<tr>";
// get main category
$query = "select category_id, name from category where parent_id = 0 order by name";
$result = mysql_query($query);
$num_cats = mysql_num_rows($result);
// loop for 2 columns
$category .= "<td valign=top>";
// mod
$num_cols=3;
$break = number_format(($num_cats )/$num_cols);
$i=1;
$k=1;
$m=1;
while($i < $num_cats){
$cat_id = mysql_result($result,$i,"category_id");
$cat_name = mysql_result($result,$i,"name");
$get_number_of_links = GetNumberOfLinks($cat_id);
$html_number_of_links = str_replace("<%number_of_links%>",$get_number_of_links,$number_of_links);
$cat_url = "browse.php?cat=$cat_id";
$category .= "<p><FONT FACE=$cat_font_face SIZE=$cat_font_size>";
$category .= "<B><A HREF=\"$cat_url\" style=\"$cat_link_style\">$cat_name</A></B> $html_number_of_links \n";
$category .= "<BR>\n";
// get sub category
$query = "select category_id, name from category where parent_id=\"$cat_id\" order by name";
$result_sub = mysql_query($query);
$num_subs = mysql_num_rows($result_sub);
$j = 0;
while(($j < $num_subs) && ($j < 3)){
$sub_id = mysql_result($result_sub,$j,"category_id");
$sub_name = mysql_result($result_sub,$j,"name");
$sub_url = "browse.php?cat=$sub_id";
$category .= "<FONT FACE=$subcat_font_face SIZE=$subcat_font_size>\n";
$category .= "<A HREF=\"$sub_url\" style=\"$subcat_link_style\">$sub_name</A> ";
$j++;
if(($j==3)&&($j < $num_subs)) {
$category .= "...\n";
}
}
if ($break == $k and $m <> $num_cols){
$category .= "</td><td valign=top>\n\n";
$k=0;
$m++;
}
$i++;
$k++;
}
$category .= "</td></tr></table>";
DisplayTemplate($template_path."index.html","\$category,\$cat,\$ma");
}
// ---------------
// main program
// ---------------
ConnectDB();
$title = $title_1101;
DisplayTemplate($template_path."header.html","\$title,\$cat,\$ma");
ShowMainPage();
DisplayTemplate($template_path."footer.html","\$cat,\$ma");
?>