# PHP menu problem

**URL:** https://forum.kirupa.com/t/php-menu-problem/258782
**Category:** programming
**Created:** [April 28, 2008, 9:37am UTC](https://forum.kirupa.com/t/php-menu-problem/258782 "2008-04-28T09:37:55Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Robertr81](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@Robertr81](https://forum.kirupa.com/u/Robertr81)
#### Post date: [April 28, 2008, 9:37am UTC](https://forum.kirupa.com/t/php-menu-problem/258782/1 "2008-04-28T09:37:55Z")

</div>

Hi! Im very basic with PHP and trying for my first time with a simple site.

I have two menus in different files. One main menu and a submenu. My problem is when i click on o link in the submenu the style “slected” disappears from my main menu. I still want to have it selected. Here below is myc code for both menus.

**main menu in header.php**  
\<div id=“menu”\>  
\<ul\>  
\<?php

$home\_url = ‘/index.php’;  
$home\_name = ‘Home’;

$news\_url = ‘/sv/nyheter/index.php’;  
$news\_name = ‘News’;

if ($\_SERVER[‘PHP\_SELF’] == "$home\_url ")  
{  
echo “\<li class=“selected”\>\<a href=’$home\_url '\> $home\_name\</a\>\</li\>”;  
}  
else  
{  
echo “\<li\>\<a href=’$home\_url '\> $home\_name\</a\>\</li\>”;  
}

if ($\_SERVER[‘PHP\_SELF’] == “$news\_url”)  
{  
echo “\<li class=“selected”\>\<a href=’$news\_url’\>$news\_name\</a\>\<li\>”;  
}  
else  
{  
echo “\<li\>\<a href=’$news\_url’\>$news\_name\</a\>\<li\>”;  
}

?\>  
\</ul\>  
\</div\>

**and code in submenu.php**

\<ul class=“newsList”\>  
\<?php

echo “\<li\>\<a href=‘2008-02-02.php’\>link1\</a\>\</li\>”;  
echo “\<li\>\<a href=‘2008-02-02.php’\>link2\</a\>\</li\>”;

?\>  
\</ul\>

when I click on “link1” in submenu I still want to have the news button in main menu selected.

i was trying to send that variable in the link with something like this but it did not work.

echo “\<li\>\<a href=‘2008-02-02.php[COLOR=red]?news\_url’[/COLOR]\>link1\</a\>\</li\>”;

(both files is included in a third file)

best regards  
/Robert
