scapenz
11-19-2010, 02:15 AM
Hey guys,
Kinda new to this php lark and wasn't able to find anywhere that could explain why this is not working correctly -
Basically i'm working on a menu that changes the UL background according to which section the page is currently on.
I have a template index.php page that changes according to index.php?page=pagename
What I have in the menu is -
<?php
$pagename = $_GET['page'];
function setcurrent($name) {
echo "<ul class='section ".$name." current'>";
}
if ($pagename == 'whybamboo' || 'environmentallysound' || 'ourclients') {
setcurrent(whybamboo);
}
else
{
echo "<ul class='section whybamboo'>";
}
?>
Can anyone explain to me why the || operators are not working and if there is a simpler way of achieving this.
I also have a problem where i'd like the title of the page to change according to the ?page=pagename variable also. Now while I can appreciate that this could be done with an array or switch conditional, what is the most common way that dynamic titles on web pages is achieved?
Cheers.
Kinda new to this php lark and wasn't able to find anywhere that could explain why this is not working correctly -
Basically i'm working on a menu that changes the UL background according to which section the page is currently on.
I have a template index.php page that changes according to index.php?page=pagename
What I have in the menu is -
<?php
$pagename = $_GET['page'];
function setcurrent($name) {
echo "<ul class='section ".$name." current'>";
}
if ($pagename == 'whybamboo' || 'environmentallysound' || 'ourclients') {
setcurrent(whybamboo);
}
else
{
echo "<ul class='section whybamboo'>";
}
?>
Can anyone explain to me why the || operators are not working and if there is a simpler way of achieving this.
I also have a problem where i'd like the title of the page to change according to the ?page=pagename variable also. Now while I can appreciate that this could be done with an array or switch conditional, what is the most common way that dynamic titles on web pages is achieved?
Cheers.