Jump to content

php script help


johnLocke

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

Archived

This topic is now archived and is closed to further replies.

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