Hello everybody,
I have tried to create a menu with 3 level but I always have a problem.
function get_cat($current_menu_cat, $count) {
global $currentlang, $prefix, $db, $user;
static $option_results;
if (!isset($current_menu_cat)) {
$current_menu_cat =0;
}
$count = $count+1;
$sql = "SELECT menu_id, menu_auth, title from ".$prefix."_menu where menu_cat = '$current_menu_cat' order by title";
$result = $db->sql_query("$sql");
$num_options = mysql_num_rows($result);
if ($num_options > 0) {
while (list($menu_cat_id, $menu_auth, $menu_title) = mysql_fetch_row($result)) {
if ($menu_auth == "registered") {
if (($userinfo[username] != "") || is_admin($admin)) {
if ($current_menu_cat!=0) {
$indent_flag = " ";
for ($x=2; $x<=$count; $x++) {
if ($count==2) {
$indent_flag .= "--> ";
}
if ($count==3) {
$indent_flag .= "--> ";
//$indent_flag_end .= "<br>";
}
}
}
}
}
if ($menu_auth == "admin") {
if (is_admin($admin)) {
if ($current_menu_cat!=0) {
$indent_flag = " ";
for ($x=2; $x<=$count; $x++) {
if ($count==2) {
$indent_flag .= "--> ";
}
if ($count==3) {
$indent_flag .= "--> ";
//$indent_flag_end .= "<br>";
}
}
}
$menu_title = $indent_flag.$menu_title;
$option_results[$menu_cat_id] = $menu_title;
get_cat($menu_cat_id, $count);
}
}
if ($menu_auth == "unregistered") {
if ($current_menu_cat!=0) {
$indent_flag = " ";
for ($x=2; $x<=$count; $x++) {
if ($count==2) {
$indent_flag .= "--> ";
}
if ($count==3) {
$indent_flag .= "--> ";
//$indent_flag_end .= "<br>";
}
}
}
}
$menu_title = $indent_flag.$menu_title;
$option_results[$menu_cat_id] = $menu_title;
get_cat($menu_cat_id, $count);
}
}
return $option_results;
}
This script create category and get the name of the cat. But I need when the befor menu level is set to admin only admin could see the other sub-level any idea????
global $currentlang, $prefix, $db, $user;
//global $currentlang, $prefix, $db;
$get_options = get_cat(0, 0);
if (count($get_options) > 0){
$categories = $_POST['cat_id'];
foreach ($get_options as $key => $value)
{
$sql_key = "SELECT menu_auth, link from ".$prefix."_menu where menu_id = '$key'";
$result_key = $db->sql_query("$sql_key");
while (list($menu_auth, $link) = mysql_fetch_row($result_key)) {
if ($menu_auth == "unregistered") {
$menu_flag = 1;
}
if ($menu_auth == "registered") {
$menu_flag = 2;
}
if ($menu_auth == "admin") {
$menu_flag = 3;
}
}
if ($menu_flag == "1") {
$options .="$value<br>\n";
}
if ($menu_flag == "2") {
if (($userinfo[username] != "") || is_admin($admin)) {
$options .="$value<br>\n";
}
}
}
}
$content .= "$options";
This script display the function.
How to create an unlimited menu system????? Thanks all