Jump to content

Holding a whole page in a variable?


s_ainley87

Recommended Posts

Hello,

 

What I am wanting to is access page data depending on what link has been pressed, so for example if the link 'link1' was hit then I would the page to load that has 'link1' details in it, and if 'link2' is pressed I want the same page to be loaded but with link2 details loaded.

 

In theory what I want is for the user to click a link and a page to load, but I only want to create one page and for the content to change depening on what link is clicked

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/104719-holding-a-whole-page-in-a-variable/
Share on other sites

<?php
if(isset($_GET['page'])){
    if($_GET['page'] == 'link1'){
         include('page1.php');
    } elseif($_GET['page'] == 'link2'){
         include('page2.php');
    } else{
         include('home.php');
    }
}
?>

 

Put a similiar code in your content div (or table??) and files will be included dynamically. Supposing your links are:

 

<a href="index.php?page=link1">Link 1</a>
<a href="index.php?page=link2">Link 2</a>

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.