Forum Moderators: coopster

Message Too Old, No Replies

php menu

         

carincik

11:19 pm on Oct 9, 2008 (gmt 0)

10+ Year Member



hi I'm a newbie in php and I need some help..
I took the lynda lessons and made changes to the site and now I'm having problems with highlighting the selected menu..

the problem is when I chose an item from the menu it has to be highlighted.. it works for index.php and index_subj.php but when I go to the item i've added to mysql (url) (like guestbook.php) the menu remains unchangeable..

this is the function for the menu with my changes..


function public_navigation($sel_subject, $sel_page, $public = true) {
$output = "<ul class=\"subjects\">";
$subject_set = get_all_subjects($public);
while ($subject = mysql_fetch_array($subject_set)) {
$output .= "<div";
if ($subject["id"] == $sel_subject['id']) { $output .= " class=\"selected\""; }
$output .= "><a href=\"" . ($subject["url"]) .
"\">{$subject["menu_name"]}</a></div>";
$page_set = get_pages_for_subject($subject["id"], $public);
$output .= "<ul class=\"pages\">";
while ($page = mysql_fetch_array($page_set)) {
$output .= "<li";
if ($page["id"] == $sel_page['id']) { $output .= " class=\"selected\""; }
$output .= "><a href=\"" . urlencode($page["id"]) .
"\">{$page["menu_name"]}</a></li>";
}
$output .= "</ul>";
}
$output .= "</ul>";
return $output;
}

I've added in my database an "url" field but I can't manage to make a good menu

the menu has submenus
I think it's not related to css, it has to be a php and mysql problem.

thanx in advance :)

[edited by: eelixduppy at 11:42 pm (utc) on Oct. 9, 2008]

omoutop

9:16 am on Oct 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



$page_set = get_pages_for_subject($subject["id"], $public);

you are calling a function inside a function? you need a class to do this

andrewsmd

12:17 pm on Oct 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can call a function inside of a function there is no need for classes as you are a newbie Object oriented programming would be very difficult for you. At first glance I see you have $subject["id"] in your first if statement but I don't see where $subject is ever defined. In PHP that if statement would always return false. What is $subject supposed to be. A variable passed in, a Session variable?