pandacrusader Posted March 7, 2006 Share Posted March 7, 2006 Alright, I've done this before, and it's taking a lot for me to remember exactly how it was done. In a perfect world, one would go to the index.php page consisting of:[code]<?PHP include ('top.php');if (!$page){ $page = "news";}include ($page . ".php");include ('bot.php');?>[/code]And be automatically shown the top third, the content in the middle, and the closing third. The links to other content then look something like this:[code]<li><a href="index.php?page=news">News</a></li>[/code]However, the result of this script is an include error that's now creating too busy of a server for me (my host must love me =) ).Any ideas why it can't find the correct file to include? I'm sure it's just a simple matter of syntax, it's been many a moon since I last coded. Thanks much in advance, PHPFreaks has always been timely and decisive!- Icbat Quote Link to comment Share on other sites More sharing options...
obsidian Posted March 7, 2006 Share Posted March 7, 2006 try something like this:[code]<?phpinclude ('top.php');// first, set a default to drop to if there isn't one in the URL$page = isset($_GET['page']) ? $_GET['page'] : 'news';include ("{$page}.php");include ('bot.php');?>[/code]basically, you've got to remember that whatever page you're trying to include is also in the same directory, but otherwise, you should be golden. Quote Link to comment Share on other sites More sharing options...
pandacrusader Posted March 7, 2006 Author Share Posted March 7, 2006 Makes sense. Thanks, Obsidian! You've helped a lot! Quote Link to comment Share on other sites More sharing options...
ricez Posted August 10, 2007 Share Posted August 10, 2007 [quote author=obsidian link=topic=87665.msg352331#msg352331 date=1141691454]try something like this:[code]<?phpinclude ('top.php');// first, set a default to drop to if there isn't one in the URL$page = isset($_GET['page']) ? $_GET['page'] : 'news';include ("{$page}.php");include ('bot.php');?>[/code]basically, you've got to remember that whatever page you're trying to include is also in the same directory, but otherwise, you should be golden.[/quote]I tried using this, and it didn't work. I am wondering why. Also, how do you go about putting a default and be able to change what $page is? Quote Link to comment Share on other sites More sharing options...
felipeebs Posted August 10, 2007 Share Posted August 10, 2007 [code=php:0]<?phpinclude ('top.php');//Why don't we try the old way?$page = $_GET['page'];if(isset($page)) { include ('$page.php');} else{ include ('home.php'); }//not tested yetinclude ('bot.php');?>[/code] 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.