Jump to content

Content Issue


capsulecore

Recommended Posts

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.
Link to comment
Share on other sites

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...
Link to comment
Share on other sites

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 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;
}[/code]

however the page will still reload to get the new content
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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