Jump to content


Photo

Content Issue


  • Please log in to reply
2 replies to this topic

#1 capsulecore

capsulecore
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 08 August 2006 - 02:07 AM

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
<?php include(home.txt);?> //link would change this to:  <?php include(info.txt);?>
<?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.

#2 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 08 August 2006 - 02:24 AM

Uhhhh you could do
$act = $_GET['act'];
if(!isset($act)) { $act = "home"; }
if($act = "home") { include("home.txt"); }
elseif ($act = "info") { include("info.txt"); }
else { echo "Inccorrect act."; }
the page would have to reload for that though.... Youre best bet is using javascript i think...
Why doesn't anyone ever say hi, hey, or whad up world?

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 08 August 2006 - 01:05 PM

Much neater to use a swtch:
// 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 act
switch($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;
}

however the page will still reload to get the new content




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users