dannyluked Posted August 8, 2009 Share Posted August 8, 2009 Hi, I have a website and each page includes a different header as the header shows the current page's link in bold (below). 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 More sharing options...
abazoskib Posted August 8, 2009 Share Posted August 8, 2009 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 More sharing options...
abazoskib Posted August 8, 2009 Share Posted August 8, 2009 and i forgot to mention, put that in a seperate php file. then include it on all your pages, to reduce down editing to one file if any changes occur. Link to comment https://forums.phpfreaks.com/topic/169381-php-header/#findComment-893734 Share on other sites More sharing options...
dannyluked Posted August 9, 2009 Author Share Posted August 9, 2009 dont completely understand this and by the way the header at the moment isnt just an image, its divs and writing! Link to comment https://forums.phpfreaks.com/topic/169381-php-header/#findComment-894203 Share on other sites More sharing options...
abazoskib Posted August 9, 2009 Share Posted August 9, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.