geektasic Posted March 30, 2009 Share Posted March 30, 2009 Hey all! Firstly; I am very new to this, so please bear with me! I just completed a tutorial which showed me how to use PHP switch with navigation. Everything works fine until I want to add another group of switch functions to "programmes.php". I understand that this is clashing with "index.php", but I'm unsure how to resolve this. I'm using another switch in "programmes.php" because it has a submenu and I need to add further varibles to each case; later. Can someone look at my files and tell me what I've done wrong? Thanks P.s. the zip folder only contains the bare bone files for you to look at. All the includes are obviously this end, so I don't have any missing files. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/151833-php-switch-navigation-error/ Share on other sites More sharing options...
lonewolf217 Posted March 30, 2009 Share Posted March 30, 2009 post the code that is causing the problem in [ code][ /code] tags and you need to be more specific about what the problem is other than "its not working". why do you say it is clashing Link to comment https://forums.phpfreaks.com/topic/151833-php-switch-navigation-error/#findComment-797253 Share on other sites More sharing options...
geektasic Posted March 30, 2009 Author Share Posted March 30, 2009 It's best to see my code to see what I mean. When you're in "programmes.php" and you click a link within the sub menu, it resorts to the "index.php" default case;. I need to know how to give each switch function a different class to make each one unique. Sorry if the answer is obvious or I've done it in completely the wrong way, but I'm very new to this index.php <?php include("includes/default/head.php"); ?> <body> <!-- Begin container --> <div id="container"> <!-- Left panel --> <div id="left_panel"> <a href="index.php"><img src="images/default/logo.gif" alt="Logo" /></a> <? //Get the page variable $page = $_GET['page']; //Our switch statement to get the right content switch($page) { //Home case "home": $content = 'includes/' . $page . '.php'; break; //People case "people": $content = 'includes/' . $page . '.php'; break; //Programmes case "programmes": $content = 'includes/' . $page . '.php'; break; //Sales case "sales_and_distribution": $content = 'includes/' . $page . '.php'; break; //Ethos case "ethos": $content = 'includes/' . $page . '.php'; break; //Contact case "contact": $content = 'includes/' . $page . '.php'; break; default: //If the variable didn't match any of the above cases do this. $content = "includes/home.php"; break; } //Include the selected content. include($content); ?> <!-- End container --> </div> </body> </html> includes/home.php <!-- Navigation --> <div id="navigation"> <ul> <li><a href="index.php?page=home"><img src="images/navigation/default/home.gif" alt="Home" /></a></li> <li><a href="index.php?page=people"><img src="images/navigation/default/people.gif" alt="People" /></a></li> <li><a href="index.php?page=programmes"><img src="images/navigation/default/programmes.gif" alt="Programmes" /></a></li> <li><a href="index.php?page=sales_and_distribution"><img src="../images/navigation/default/sales_and_distribution.gif" alt="Sales & Distribution" /></a></li> <li><a href="index.php?page=ethos"><img src="images/navigation/default/ethos.gif" alt="Ethos" /></a></li> <li><a href="index.php?page=contact"><img src="images/navigation/default/contact.gif" alt="Contact" /></a></li> </ul> </div> </div> <!-- Body --> <div id="body"> I'm the homepage! <!-- End body --> </div> includes/programmes.php <!-- Navigation --> <div id="navigation"> <ul> <li><a href="index.php?page=home"><img src="images/navigation/default/home.gif" alt="Home" /></a></li> <li><a href="index.php?page=people"><img src="images/navigation/default/people.gif" alt="People" /></a></li> <!--Programme sub menu --> <li><a href="index.php?page=programmes"><img src="images/navigation/default/programmes.gif" alt="Programmes" /></a></li> <li><a href="index.php?page=popular_factual"><img src="images/navigation/programmes/popular_factual.gif" alt="Popular Factual" /></a></li> <li><a href="index.php?page=specialist_factual"><img src="images/navigation/programmes/specialist_factual.gif" alt="Specialist Factual" /></a></li> <li><a href="index.php?page=factual_entertainment"><img src="images/navigation/programmes/factual_entertainment.gif" alt="Factual Entertainment" /></a></li> <li><a href="index.php?page=online"><img src="images/navigation/programmes/online.gif" alt="Online" /></a></li> <li><a href="index.php?page=sales_and_distribution"><img src="../images/navigation/default/sales_and_distribution.gif" alt="Sales & Distribution" /></a></li> <li><a href="index.php?page=ethos"><img src="images/navigation/default/ethos.gif" alt="Ethos" /></a></li> <li><a href="index.php?page=contact"><img src="images/navigation/default/contact.gif" alt="Contact" /></a></li> </ul> </div> </div> <!-- Body --> <div id="body"> <? //Get the page variable $page = $_GET['page']; //Our switch statement to get the right content switch($page) { //Programmes case "popular_factual": $content = 'includes/programmes/' . $page . '.php'; break; case "specialist_factual": $content = 'includes/programmes/' . $page . '.php'; break; case "factual_entertainment": $content = 'includes/programmes/' . $page . '.php'; break; case "online": $content = 'includes/programmes/' . $page . '.php'; break; default: //If the variable didn't match any of the above cases do this. $content = "includes/programmes/popular_factual.php"; break; } //Include the selected content. include($content); ?> <!-- End body --> </div> Link to comment https://forums.phpfreaks.com/topic/151833-php-switch-navigation-error/#findComment-797265 Share on other sites More sharing options...
geektasic Posted March 30, 2009 Author Share Posted March 30, 2009 Anyone? Link to comment https://forums.phpfreaks.com/topic/151833-php-switch-navigation-error/#findComment-797288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.