Jump to content

PHP header...


dannyluked

Recommended Posts

Hi,

I have a website and each page includes a different header as the header shows the current page's link in bold (below).

 

home.jpg

 

members.jpg

 

Is there any way I could have one php page (header.php) that would show exactly the same as this for example by grabbing a variable in another file?

 

PS. I wouldnt mind if I had to use MySQL!

Link to comment
https://forums.phpfreaks.com/topic/169381-php-header/
Share on other sites

a quick way would be to use the value for $_SERVER['PHP_SELF'] and have a switch statement like:

 

switch($url)
    case "index.php":
    $headerImg = PATH_TO_IMAGE;
    break;
    case "secondPage.php":
    $headerImg = PATH_TO_IMAGE2;
    break;

and so on..

Link to comment
https://forums.phpfreaks.com/topic/169381-php-header/#findComment-893731
Share on other sites

a quick way would be to use the value for $_SERVER['PHP_SELF'] and have a switch statement like:

 

switch($url)
    case "index.php":
    $headerImg = PATH_TO_IMAGE;
    break;
    case "secondPage.php":
    $headerImg = PATH_TO_IMAGE2;
    break;

and so on..

 

$_SERVER['PHP_SELF'] gives you the current page address. now based on that, you can set up a switch statement, perhaps to trigger the "active" state of your header. so for example, if the address bar says "members.php" and you want the members page tab in yellow, you could use the swtich statement like i set up for you to make that tab the one that is yellow

Link to comment
https://forums.phpfreaks.com/topic/169381-php-header/#findComment-894384
Share on other sites

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.