PHP 'if' problem
Hi all, could someone please help me before I tie bricks around my neck and throw myself in the Loch?
Consider the following PHP snippet:
Basically, a menu with a sub-menu. Each page is given a unique name via php. In this case, if page is 'webhome', the class 'currentpage' is assigned and certain styling is applied. Obviously, the active page is also de-linked. No problems with this part.
The next 'if' is causing me grief however. Again, page name is checked and actions carried out accordingly. Here, the page webdesign is allocated the class 'currentpage' and styling applied. The styling works perfectly.
My problem is that, despite the second instance of the Design page not have an <a> tag, the link is still active on the actual Design page. The link in the first 'if' statement appears to be overriding the settings in the second 'if' statement.
Any ideas please? I know it's bound to be something blindingly obvious, but you know what it's like; stare at the code too long and you can't see the wood for the trees!
Cheers!
Consider the following PHP snippet:
| Code: |
| <ul>
<?php if ($thisPage=='webhome') {echo '<li class="currentpage">Accessible Web Services <ul> <li><a href="/web/web-design.php"> - Design</a></li> <li><a href="#"> - Evaluation</a></li> <li><a href="#"> - Conversion</a></li> </ul>';} if ($thisPage=='webdesign') {echo '<li><a href="/web/web-home">Web Services <ul> <li class="currentpage"> - Design</li> <li><a href="/web/web-evaluation"> - Evaluation</a></li> <li><a href="/web/web-conversion"> - Conversion</a></li> </ul>';} else {echo '<li><a href="/web/web-home.php">Web Services</a>';}?></li> </ul> |
Basically, a menu with a sub-menu. Each page is given a unique name via php. In this case, if page is 'webhome', the class 'currentpage' is assigned and certain styling is applied. Obviously, the active page is also de-linked. No problems with this part.
The next 'if' is causing me grief however. Again, page name is checked and actions carried out accordingly. Here, the page webdesign is allocated the class 'currentpage' and styling applied. The styling works perfectly.
My problem is that, despite the second instance of the Design page not have an <a> tag, the link is still active on the actual Design page. The link in the first 'if' statement appears to be overriding the settings in the second 'if' statement.
Any ideas please? I know it's bound to be something blindingly obvious, but you know what it's like; stare at the code too long and you can't see the wood for the trees!
Cheers!
| Gary Miller wrote: | ||
|
I think you'll find you are missing an </a>.
my mind is on a permanent tangent
Well...that took all of about 10 secs to insert, upload and check!!!
Thanks Rich; sometimes, you just kind've get too immersed in things...
Thanks Rich; sometimes, you just kind've get too immersed in things...
took me a while to spot it too 
my mind is on a permanent tangent
my mind is on a permanent tangent
For future references, Brugbart has a Tutorial on If Then Else and ElseIf Statements
I think you to verify the syntax of if and if else statement.
It is not problem. I think that php is the simple and common langguage and used more than other langguage.
Would it not make better sense to apply the 3 equal signs? That way it also compares the type, and you avoid problems such as if (0 == 'whatever').
Changes since the previous release candidate include:
Further bug fixes in the built-in web server.
PHP-FPM is no longer marked as EXPERIMENTAL.
Several improvements and bug fixes in the Zend Engine, Core and other extensions.
Further bug fixes in the built-in web server.
PHP-FPM is no longer marked as EXPERIMENTAL.
Several improvements and bug fixes in the Zend Engine, Core and other extensions.
Your coding seems some internal problem when loop being execute. You try in the following format.
<?php
$myNodesID = arg(1);
$taxArray=taxonomy_node_get_terms($myNodesID);
if (($taxArray[1]->name == "News") || (arg(0) == "taxonomy" && arg(1) == "term" && arg(2) == 1))
{
return TRUE;
}
else {
return FALSE;
}
?>
[link removed by admin]
<?php
$myNodesID = arg(1);
$taxArray=taxonomy_node_get_terms($myNodesID);
if (($taxArray[1]->name == "News") || (arg(0) == "taxonomy" && arg(1) == "term" && arg(2) == 1))
{
return TRUE;
}
else {
return FALSE;
}
?>
[link removed by admin]


