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 Link to comment https://forums.phpfreaks.com/topic/4275-indexphppagenewsphp-include-function/ 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. Link to comment https://forums.phpfreaks.com/topic/4275-indexphppagenewsphp-include-function/#findComment-14884 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! Link to comment https://forums.phpfreaks.com/topic/4275-indexphppagenewsphp-include-function/#findComment-14896 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? Link to comment https://forums.phpfreaks.com/topic/4275-indexphppagenewsphp-include-function/#findComment-319975 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] Link to comment https://forums.phpfreaks.com/topic/4275-indexphppagenewsphp-include-function/#findComment-319984 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.