xplicit503 Posted April 1, 2006 Share Posted April 1, 2006 I found your site while browsing through google and it seemed to be a great community. I looked up in this site what I had needed in the FAQ section of the "Newbie Help Forum", which was the include code/php linking. Now from what I have read in other threads people have been flamed for "retarded" questions such as the one I am asking, but I did just start to scrape the surface of the php world, and I am in need of assistance.Current Code in use:[code]<?php include 'news.php'; switch($_GET['id']){ case 'news': include 'news.php'; break; case 'courses': include 'courses.php'; break; ?>[/code]The problem is that it works, but when I click on my links it still leaves the default included content in the table.I've been searching for a few days now, and this was my last option. If you need to see the actual site please let me know. Thanks. Quote Link to comment Share on other sites More sharing options...
toplay Posted April 1, 2006 Share Posted April 1, 2006 Hi, welcome to this forum.I'm not sure what you mean since you didn't post a whole lot of code. However, I can share a couple of things I noticed.1) The news.php is included all the time at the top, and it will get included again if the id is "news". I don't think that's what you intended. You might want to remove the first one or use include_once() or require_once() on both statements.2) You don't have an ending right curly brace that's needed to close off the switch statement.hth. Quote Link to comment Share on other sites More sharing options...
xplicit503 Posted April 1, 2006 Author Share Posted April 1, 2006 My appologizes for the lack of information, but I needed to change the directory protection off. To give the site url to actually view the problem in person. [a href=\"http://www.xplicit.chatvisual.com/bt/\" target=\"_blank\"]Link to website[/a]1.) I have placed in the include_once() like so:[code]<?php include_once('news.php');switch($_GET['id']){case 'courses':include 'courses.php';break;case 'events':include 'events.php';break;case 'staff':include 'staff.php';break;case 'tools':include 'tools.php';break;case 'about':include 'about.php';break;}?>[/code]Well the right curly brace was missing in the first post for some reason. But it is in there now. Although the and "news" advice fixed somethings, along with the include_once() code. But now click on the courses button.(The only operational one so far on the link) You still see at the top of the content box the old content from the news.php Quote Link to comment Share on other sites More sharing options...
toplay Posted April 1, 2006 Share Posted April 1, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]You still see at the top of the content box the old content from the news.php[/quote]Sorry, I don't see or understand what you mean because I don't know what news.php really contains. But if you're seeing it, well it's because news.php is being included every time! You got it at the top of the page.You may already know this, but the links for the "About", "Tools", etc. are using "page=" instead of "id=". Your code shown is using "id" and not "page".Read up on include/require include_once/require_once at php.net. Quote Link to comment Share on other sites More sharing options...
xplicit503 Posted April 1, 2006 Author Share Posted April 1, 2006 Hmm, The news.php's content is text that says: "Coding CMS initiated. Site is still about 30% done." Appologies on me being extremly unclear, its just that I have been working on this for a few hours and my head hurting.What could I do to make the news.php show up just on the index.php and no other page? Currently I went back to my original understanding of the include/linking code from the FAQ:[code] <TD width="481" ROWSPAN=4 valign="top" class="content03"> <div align="left"> <?php include_once("news.php"); ?> <?php switch($_GET['id']){ case 'courses': include 'courses.php'; break; case 'events': include 'events.php'; break; case 'staff': include 'staff.php'; break; case 'tools': include 'tools.php'; break; case 'about': include 'about.php'; break; }?> </div> </TD> </TR> <TR>[/code]Im not certain on where to put in the switch code (thus reason why I am in the newbies forum.) Quote Link to comment Share on other sites More sharing options...
toplay Posted April 1, 2006 Share Posted April 1, 2006 Whatever way you determine it's the index page, use it to only display the news.php.if (something) {include_once("news.php");}That "something" condition, only you know.Example:if (FALSE !== strpos($_SERVER['PHP_SELF'], 'index.php')) {include_once("news.php"); // We're on the index page} Quote Link to comment Share on other sites More sharing options...
xplicit503 Posted April 1, 2006 Author Share Posted April 1, 2006 Ah, after so long I finally got the script where I want it! I added in a the following line:[code] <?php switch($_GET['id']){ default: include_once('news.php'); break;[/code]Instead of the include code it made more sense to make the default in the script itself include the news.php only once. Thanks toplay for your assistance and ability to hang in there with me while I struggled to explain php in the little way that I could. Also I did like the meathod you helped me out with, instead of just giving me the code it was step to step and made me think on my own. Quote Link to comment 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.