Jump to content

Recommended Posts

hey, i have got this script from thybag.co.uk which i can use to display several pages on the same page such as "www.website.com/index.php?page=2"

 

can anyone help me so i can have subpages as well such as "www.website.com/index.php?page=1&subpage=2

 

thanks

 

 

----------

this is the original script from http://thybag.co.uk/index.php?p=Tutorials&ind=23

 

</php 

if(!$show){ $show = $HTTP_GET_VARS['show']; } 

if($show=="page1"){ 
?> 

PAge 1 content here, 

<?php 
} 
elseif($show=="page2"){ 
?> 

page 2 content here 

<?php 
} 
elseif($show=="page3"){ 
?> 

and finally page 3 content here 

<?php 
} 
else{ 
?> 

page for if none is requested 

<?php 
} 
?>

Link to comment
https://forums.phpfreaks.com/topic/63429-php-script-help/
Share on other sites

</php 

function doSubPage($subpage)
{
    switch($subpage)
    {
        case 1:
            require("subpage1.htm");
            break;
        case 2:
            require("subpage2.htm");
            break;
        case 3:
            require("subpage3.htm");
            break;
        default:
            require("subdefault.htm");
            break;
    }
}

//
// Figure out if there is a variable in $page AND $subpage
//  ---- BEGIN ---->
//
if(!isset($page))
{
    $page = $_GET['page'];
}

if(!isset($subpage)
{
    $subpage = $_GET['subpage'];
}
//
// <---- END ----
//

switch($page)
{
    case 1:
        require("page1.htm");
        doSubPage($subpage);
        break;
    case 2:
        require("page2.htm");
        doSubPage($subpage);
        break;
    case 3:
        require("page3.htm");
        doSubPage($subpage);
        break;
    default:
        require("default.htm");
        doSubPage($subpage);
        break;
} 
?>

 

Changes:

  • HTTP_GET_VARS is older reapcled with: $_GET
  • Instead of including all the html on this page you can do it from files now this allows you php code and html code to be in 2 diffrent files

 

Note: I didnt test it not 100% sure if it works but i think it will

Link to comment
https://forums.phpfreaks.com/topic/63429-php-script-help/#findComment-316140
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.