tomhoad Posted March 16, 2009 Share Posted March 16, 2009 Hi, I'm trying to create a navigation bar using PHP: <!-- ADMIN NAV Checks to see if the page is the current one, and if so doesn't display a link (just bolds it) Tom 03/03/09 --> <?php if ($thispage == "news_admin") echo "<b>News</b>"; else echo '<a href="news-add.php">News</a>'; ?> | <?php if ($thispage == "bio_admin") echo "<b>Biography</b>"; else echo '<a href="bio_edit.php">Biography</a>'; ?> | <?php if ($thispage == "events_admin") echo "<b>Events</b>"; else echo '<a href="events_admin.php">Events</a>'; ?> | <?php if ($thispage == "comments_admin") echo "<b>Comments</b>"; else echo '<a href="comments_admin.php">Comments</a>'; ?> | <?php if ($thispage == "gallery_admin") echo "<b>Gallery</b>"; else echo '<a href="gallery/">Gallery</a>'; ?> This works fine, until I go into the gallery (as this is a folder). Then the links mess up as they are looking for files within Gallery folder that do not exist. I have had a play around with PHP_SELF but I can't seem to get that to work. Does anyone have any tips on how to achieve this? Also, is there a way of shortening the code, perhaps by passing the variables into an array or something? Link to comment https://forums.phpfreaks.com/topic/149736-php-navigation-bar/ Share on other sites More sharing options...
Renlok Posted March 17, 2009 Share Posted March 17, 2009 you need to add a HTML base tag to your page http://www.w3schools.com/TAGS/tag_base.asp Link to comment https://forums.phpfreaks.com/topic/149736-php-navigation-bar/#findComment-786315 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.