capsulecore Posted August 8, 2006 Share Posted August 8, 2006 Ive been looking for a way to open a link on a page without having the whole page reload. For example the link would be in the navigation, (part of the header include) and would swap out the include for the body:<?php include(header.txt);?> //would have the link[color=red]<?php include(home.txt);?>[/color] //link would change this to: [color=green]<?php include(info.txt);?>[/color]<?php include(footer.txt);?>Is there any way to do this that isnt overly complicated? I've tried using layers but the layers wouldnt properly resize the page, same with iframes. Quote Link to comment https://forums.phpfreaks.com/topic/16851-content-issue/ Share on other sites More sharing options...
corbin Posted August 8, 2006 Share Posted August 8, 2006 Uhhhh you could do[code=php:0]$act = $_GET['act'];if(!isset($act)) { $act = "home"; }if($act = "home") { include("home.txt"); }elseif ($act = "info") { include("info.txt"); }else { echo "Inccorrect act."; }[/code]the page would have to reload for that though.... Youre best bet is using javascript i think... Quote Link to comment https://forums.phpfreaks.com/topic/16851-content-issue/#findComment-70922 Share on other sites More sharing options...
wildteen88 Posted August 8, 2006 Share Posted August 8, 2006 Much neater to use a swtch:[code=php:0]// check that $_GET['act'] exists, if it does use its value, else set a defualt value$act = isset($_GET['act']) ? $_GET['act'] : 'home';// now we check the value of actswitch($act){ // think of this as an if statement that says if $act is equal to home, or info or pruducts include $act.php case 'home': case 'info': case 'products': include $act . '.php'; break; // and this as the else bit case defualt: die("Invalid value for act"); break;}[/code]however the page will still reload to get the new content Quote Link to comment https://forums.phpfreaks.com/topic/16851-content-issue/#findComment-71112 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.