bob_arctor Posted June 22, 2008 Share Posted June 22, 2008 Hello all, Pretty new to this - Here's my problem. Currently using a php include(),works fine, to handle navigation - <div id="nav"> <ul> <li><a <?php if ($this_page=="Home") echo "id=\"currentpage\""; ?> href="index">Home</a></li> <li><a <?php if ($this_page=="About") echo "id=\"currentpage\""; ?> href="about">About</a></li> etc. </ul> </div> Several pages (error 404, privacy etc.) require that only some nav options are available. I do not want to code an include for each page - kind of defeats the point. Tried this - <?php $page = $this_page; switch($page){ case "Home": /*some code here*/ break; etc. etc. case "404": echo ' <div id="nav"> <ul> <li><a <?php if ($this_page=="Home") echo "id=\"currentpage\""; ?> href="index">Home</a></li> <li><a <?php if ($this_page=="Contact") echo "id=\"currentpage\"";?> href="http="contact">Contact</a></li> </ul> </div> '; break; default: break; } ?> This gives me the nav bars which literally display "href ="index">Home" "href ="contact">Contact" contained inside. Where am I going wrong ? I'm pretty sure I should be revisiting php 101. I just cannot see it. Is there a more eloquent way to go about this ? Regards. Quote Link to comment https://forums.phpfreaks.com/topic/111334-solved-handling-nav-with-switch-problem/ Share on other sites More sharing options...
.josh Posted June 22, 2008 Share Posted June 22, 2008 case "404": echo "<div id='nav'> <ul> <li><a id = 'currentpage' href='$this_page'>$this_page</a></li> <li><a id = 'currentpage' href='$this_page'>$this_page</a></li> </ul> </div> "; break; Quote Link to comment https://forums.phpfreaks.com/topic/111334-solved-handling-nav-with-switch-problem/#findComment-571542 Share on other sites More sharing options...
bob_arctor Posted June 22, 2008 Author Share Posted June 22, 2008 Thank you. I was trying to do some hugely questionable (dumb) things with backslash and apostrophes within that case. Regards. Quote Link to comment https://forums.phpfreaks.com/topic/111334-solved-handling-nav-with-switch-problem/#findComment-571578 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.