Hi,
I am having problem with conditional code not executing correctly now that I've put it into a function.
At the top of my document I set the current page with a variable:
<?php $currentpage = "contact"; ?>
...then I show my function to write out a nav bar link:
<?php
function nav_child($PageLabel, $PageName, $PageURL, $PageAlt="") {
global $SkinDir;
echo "<tr>";
echo "<td><img src='$SkinDir/spacer.gif' width='1' height='1' border='0'></td>";
echo "<td valign='middle' nowrap='nowrap' height='11'>";
if ( $currentpage == "home" ) {
// Link Turned ON (BLUE)
echo "<img align='center' src='$SkinDir/nav2_bullet_on.gif' height='11' alt='$PageAlt' border='0'>";
} else {
// Link Turned OFF (WHITE)
echo "<a class='noline' href='$PageURL' target='_self'>";
echo "<img align='center' src='$SkinDir/nav2_bullet.gif' height='11' alt='$PageAlt' border='0'></a>";
}
if ( $currentpage == "home" ) {
// Link Turned ON (BLUE)
echo "<span class='nav2on'>$PageName</span>";
} else {
// Link Turned OFF (WHITE)
echo "<a class='noline' href='$PageURL' target='_self'>";
echo "<span class='nav2'>$PageName</span></a>";
}
echo "</td>";
echo "</tr>";
}
?>
...later on, when I write out the nav bar...
<?php nav_child("home", "Home", "index.php", "Home..."); ?>
<?php nav_child("about", "About Us", "about.php", "About..."); ?>
<?php nav_child("contact", "Contact Me", "contact.php", "Contact Info..."); ?>
The CONTACT link should show up blue with a different image/CSS class since the $currentpage variable is set to "contact" but it all 3 links show up the same.
Before I converted the code into a function, it all worked.
Please help me, I'm new to PHP and very clueless!
Thx,
Jeremy