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
https://forums.phpfreaks.com/topic/34597-dynamic-php-web-pages-question/
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...
[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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.