akforce Posted September 28, 2009 Share Posted September 28, 2009 Hey I'm making a website, but i seem have some trouble, I am using php on my menu bar to include the content in the content area, but my problem is i want to include another DIV i have designed into another part of the page, but only for the home, the about page etc will not have this included, so my question is How do i include multiple items on a page but only relative to that page: Here is my current code: This is on my config.php <?php function page($page){ $page = $_GET['page']; switch ($page) { // Main Menu case '': case 'home': include('modules/home.php'); include('modules/test.php'); break; case 'farms': include('modules/farms.php'); break; case 'forums': include('modules/forums.php'); break; case 'news': include('modules/news.php'); break; }} this is how i have called it on the website: Menu Bar: <div class="links"><a href="index.php?page=home">Home</a></div> <div class="links"><a href="index.php?page=farms">Our Farms</a></div> Include in content area: <?php page($page); ?> i appreciate any help you can provide, thanks in advance. Link to comment https://forums.phpfreaks.com/topic/175827-php-includes/ Share on other sites More sharing options...
jjacquay712 Posted September 28, 2009 Share Posted September 28, 2009 I would use the environment variables to see what PHP script is executing, and if it is anything else than the home page, don't include it. Link to comment https://forums.phpfreaks.com/topic/175827-php-includes/#findComment-926502 Share on other sites More sharing options...
akforce Posted September 28, 2009 Author Share Posted September 28, 2009 could you post an example please ? Link to comment https://forums.phpfreaks.com/topic/175827-php-includes/#findComment-926509 Share on other sites More sharing options...
redarrow Posted September 28, 2009 Share Posted September 28, 2009 if you use include to many times you get a error that normal.... the php functions you can try are the following.... include() include_once() require() require_once() There also others like file_get_contents() More advance one Curl socket's Link to comment https://forums.phpfreaks.com/topic/175827-php-includes/#findComment-926516 Share on other sites More sharing options...
akforce Posted September 28, 2009 Author Share Posted September 28, 2009 so i change my config file to: case 'home': include('modules/home.php'); include_once('modules/test.php'); break; and to call it in the php home file? <?php ... not to sure on this part sorry im a pure php novice Link to comment https://forums.phpfreaks.com/topic/175827-php-includes/#findComment-926540 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.