tsluss Posted February 13, 2007 Share Posted February 13, 2007 I'm working on a website for my boss and I'm a novice at PHP at the moment, however I felt this was within my grasp. I am running into some issues though and was hoping another set of eyes my have some recommendations for me. First of all I'm building the website in all <div> and formated with CSS. What I'm shooting for is the standard left hand side bar navigation menu which a user clicks on and once the button is clicked I want the body <div> to reload with an included file. This doesn't need to be elaborate, it's a small site, so a simple setup is fine for this. I have tried several variations on this site, but basically what I was trying to do was use $_GET to get the variable value once the link was clicked and then use a switch statement to determine what file is to be displayed. Here is an example of what I have so far: Code for one of the buttons: <div class="button_top"> <a href="index.php?location=home"> <img alt="Home" class="button" name="btn1" src="images/home_up.gif" onmouseover"home_over()" onmouseout="home_normal()" onmousedown="home_down()" alt="Home" /></a> </div> Code for the body <div> where the switch statement is: <?php switch ($_GET['location']) { case 'home': include ("home.php"); break; case 'services': include ("services.php"); break; default: include ("home.php"); break; } ?> There will of course be more than this once I'm finished, but I'm trying to get these two working properly before I go on. I have also tried having a small snippet of code at the begining of the file to assign the variable $location a value and set my switch on it but if it was empty to default the include to home.php and still had no luck. If anyone has any input I would greatly appreciate it. Link to comment https://forums.phpfreaks.com/topic/38251-help-with-some-menu-navigation-code/ Share on other sites More sharing options...
13th_Star Posted February 13, 2007 Share Posted February 13, 2007 the code looks fine to me, are you trying to change the page within a certain div on youe page or the hole page all together? if yes then wha tyou need is javascript. if not and your getting ablank page try this: <?php $location = $_GET['location']; switch ($location){ case "home": include "home.php"; break; case "services": include "services.php"; break; default: include "home.php"; break; } ?> Link to comment https://forums.phpfreaks.com/topic/38251-help-with-some-menu-navigation-code/#findComment-183257 Share on other sites More sharing options...
tsluss Posted February 13, 2007 Author Share Posted February 13, 2007 OK, well I've identified the source of the problem and as it turns out it looks like I've been spinning my wheels. I've been running PHP Triad on my computer to do the coding and testing locally versus uploading it to a server. After reading the reply here and seeing that my code was good, I uploaded it and it works just fine on the server. Novice mistake I suppose. Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/38251-help-with-some-menu-navigation-code/#findComment-183265 Share on other sites More sharing options...
13th_Star Posted February 13, 2007 Share Posted February 13, 2007 Hey not a problem you should stop using PHP Triad (what ever it is lol, i havent a clue!) and try using xampp Link to comment https://forums.phpfreaks.com/topic/38251-help-with-some-menu-navigation-code/#findComment-183271 Share on other sites More sharing options...
tsluss Posted February 13, 2007 Author Share Posted February 13, 2007 Will give that a try, PHP Triad basically installs Apache, PHP, and MySQL locally and looks like the basics of them all, but it's possible that (I haven't checked) it might be a slightly outdate version of PHP. Thanks for the tip though. Link to comment https://forums.phpfreaks.com/topic/38251-help-with-some-menu-navigation-code/#findComment-183272 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.