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
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!

Link to comment
Share on other sites

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";
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.