compile_dir = $real_path.'templates_c'; $body->template_dir = $real_path.'templates'; $body->config_dir = $real_path.'configs'; $db->db_connect($host, $dbuser, $password); # connect to database $db->db_select($database); # select database $array = array(); $category_links = ""; $index_link = ""; if($category) { $sql = "select page_id, LinkCategoryID from paging where pagename = \"$category\" limit 1"; $db->db_query($sql); $page_id = $db->db_assocset(); $sql = "select URL, Title, Description from Links where page_id = " . $page_id[0]['page_id'] . " order by Title"; $db->db_query($sql); $link_info = $db->db_assocset(); for($i = 0; $i < count($link_info); $i++) { $array[$i]['content'] = "" . $link_info[$i]['Title'] . "
\n" . $link_info[$i]['Description'] . "

"; } $sql = "select pagename from paging where LinkCategoryID = " . $page_id[0]['LinkCategoryID']; $db->db_query($sql); $cat_links = $db->db_assocset(); if($cat_links) { for($i = 0; $i < count($cat_links); $i++) { $category_links = $category_links . "[ " . ($i+1) . " ]  \n"; } } $index_link = '<< Directory index'; $body->assign('category', preg_replace('/[-1-9]/', ' ', $category)); } else { ############################################################ # select categories ############################################################ $sql = "select * from LinkCategories order by LinkCategoryName"; # select all the categories $db->db_query($sql); $categories = $db->db_assocset(); $num_cats = count($categories); # count number of categories $div_num = ceil($num_cats / $cols); # obtain number of rows to place per column in directory index ############################################################ # build array here ############################################################ for($i = 0, $j = 0, $k = 0; $i < $num_cats; $i++) { $array[$i]['content'] = "" . " " . trim($categories[$j]['LinkCategoryName']) . "
" ; if($k == $div_num-1 && ($num_cats - $j) > 0) { $i++; $num_cats++; $k = -1; $array[$i]['content'] = ""; } $j++; $k++; } } $body->assign('category_loop', $array); $body->assign('category_links', $category_links); $body->assign('index_link', $index_link); $body->display('category_index.tmpl'); ?>