Jump to content

Dynamic PHP web pages question


hhisc383

Recommended Posts

Hello! I hope you guys can help. I'm new to PHP...so I apologize ahead of time

on 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:

<?php
if ($_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?
Link to comment
Share on other sites

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...
Link to comment
Share on other sites

[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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.