Hi,
I am building my new website and I want to confine the menu to one file, but make it so that the user can see what page he/she is on. For this I came up with the following code:
Where $pagenumber = 'inputvalue' in $_GET from the URL.
The menu is then below, as:
This works absolutely fine until I go to the top-level domain where there is no "$_GET['page']" input for the script to pick up on. I need it to recognise a non-input as the homepage, so that I don't have to redirect it to " /index.php?page= page1 ".
I have tried a few wacky and wonderful ways of doing this but none have been successful. Does anybody have any solutions or suggestions?
Many thanks,
I am building my new website and I want to confine the menu to one file, but make it so that the user can see what page he/she is on. For this I came up with the following code:
Code:
<?php $page = $_GET['page']; ?> <?php $page1 = 'page1'; $page2 = 'page2'; $page3 = 'page3'; $page4 = 'page4';?>
The menu is then below, as:
Code:
<?php if ($page == $page1) {echo "<div id=\"menuon\"><a href=\"/index.php?page=$page1\">Homepage</a></div>";} else {echo "<div id=\"menuoff\"><a href=\"/index.php?page=$page1\">Homepage</a></div>";} ?> <?php if ($page == $page2) {echo "<div id=\"menuon\"><a href=\"/index.php?page=$page2\">Some Page</a></div>";} else {echo "<div id=\"menuoff\"><a href=\"/index.php?page=$page2\">Some Page</a></div>";} ?>
I have tried a few wacky and wonderful ways of doing this but none have been successful. Does anybody have any solutions or suggestions?
Many thanks,
Comment