s_ainley87 Posted May 8, 2008 Share Posted May 8, 2008 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 More sharing options...
Rohan Shenoy Posted May 8, 2008 Share Posted May 8, 2008 <?php //Method 1: include("path/to/file.php"); //Method 2: $content=file_get_contents("path/to/file.php"); echo $content; ?> Be careful as some elements of the page may not be rendered properly in 2nd method. Link to comment https://forums.phpfreaks.com/topic/104719-holding-a-whole-page-in-a-variable/#findComment-535970 Share on other sites More sharing options...
Fadion Posted May 8, 2008 Share Posted May 8, 2008 <?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> Link to comment https://forums.phpfreaks.com/topic/104719-holding-a-whole-page-in-a-variable/#findComment-536008 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.