Jump to content

[SOLVED] Coloured menus


ChrisML123

Recommended Posts

I'm trying to write a menu that will automatically change the colour of the active page to red.

 

In this example below, $page is recieved through $_GET, meaning that, in the case of the current page being about.php, $page == "about":

 

The first case statement echos a non clickable red menu item.

The second a standard white link.

 

Sadly it doesn't work, either giving me duplicates, or no items at all. Any ideas?

 

 

switch ($page) {

case "about":

    echo ('<p align="right" class="style2" font color="#ff0000">about the artist</p><p align="right" class="style3">');

    echo ('<p align="right" class="style2"><a href="?page=about">about the artist</a></p><p align="right" class="style3">');

case "bandw":

    echo ('<span class="style3on">b&w</span><br>');

    echo ('<a href="?page=bandw">b&w</a><br>');

case "colour":

    echo ('<span class="style3on">colour</span><br>');

    echo ('<a href="?page=colour">colour</a><br>');

}

 

EG 1. where $page=="main", no menus appear at all

EG 2. where $page=="about", I get two of every item.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/128304-solved-coloured-menus/
Share on other sites

another problem solved with session variables!

 

set each page with a session variable that is unique from the others, example page name. Then have a custom function or tons of if statements. You could do if this session var is = to page name then font color is red, else if and continue!

There are a lot of problems with your switch statement... try this...

switch ($page) {
case "about":
    echo ('<p align="right" class="style2" font color="#ff0000">about the artist</p><p align="right" class="style3">');
    echo ('<p align="right" class="style2"><a href="?page=about">about the artist</a></p><p align="right" class="style3">');
break;
case "bandw":
    echo ('<span class="style3on">b&w</span><br>');
    echo ('<a href="?page=bandw">b&w</a><br>');
break;
case "colour":
    echo ('<span class="style3on">colour</span><br>');
    echo ('<a href="?page=colour">colour</a><br>');
break;
default:
    echo "No options are in the switch statement for this value";
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.