hhisc383 Posted January 17, 2007 Share Posted January 17, 2007 Hello! I hope you guys can help. I'm new to PHP...so I apologize ahead of timeon the index, I have the header, menu to the left, page content section to the right, and the footer. i just want the page content section of the page to change with this:<?phpif ($_GET['go']=='aboutus') {include 'aboutus.php';}?>How can I do that? I tried to do it, but it would just put the page it was fetching above what was already in the content section of the index page. how can i make that content part change each time there is a new request? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 17, 2007 Share Posted January 17, 2007 if ($_GET['go']=='aboutus') {include 'aboutus.php';}else{include 'indexContent.php';}Don't put your index content unless you know there isn't another include, or else, kinda duh, it will show up... Quote Link to comment Share on other sites More sharing options...
taith Posted January 17, 2007 Share Posted January 17, 2007 assuming your are variable based, it wouldnt matter where you include() it...if their not... you need to include() it exactly where you want the file to show. Quote Link to comment Share on other sites More sharing options...
marcus Posted January 17, 2007 Share Posted January 17, 2007 What Jesirose said would work. But to make it much easier if you had more than one page and instead of including each page separately you could do something like:[code=php:0]$page = $_GET['go'];if(isset($page)){ if(file_exists("$page.php")){ include("$page.php"); }else { header("Location: index.php"); }}else {include("indexContent.php");}[/code]Each file name would be $page.php, say $page was contact, it would include contact.php, etc... Quote Link to comment Share on other sites More sharing options...
marcus Posted January 17, 2007 Share Posted January 17, 2007 [quote author=taith link=topic=122835.msg507068#msg507068 date=1169057091]assuming your are variable based, it wouldnt matter where you include() it...if their not... you need to include() it exactly where you want the file to show.[/quote]What you're saying is[code=php:0]<?php//have you top part here//put your include filename here for content//put your footer here?>[/code] Quote Link to comment Share on other sites More sharing options...
hhisc383 Posted January 17, 2007 Author Share Posted January 17, 2007 thanks for all the quick replies. i'm going to sort through this...like i said, i'm totally new to php, so it all looks a little confusing. 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.