Jump to content

PHP Navigation Bar


tomhoad

Recommended Posts

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

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.