Jump to content

[SOLVED] Dynamic includes


freelancer

Recommended Posts

Check out this page ( http://www.team-kommando.com/web ), TEAM by navigation and click on Cranx link. See, this file ( cranx.html ) will be included right below the the team.php page, but I want that it would come like all other includes - to clear page - without TEAM page.

 

Here is code I'm useing in index.php:

 

<?php

$pages = array(
                'news'     => 'news/news.php',
                'articles' => 'news/archive.php',
                'team'     => 'team.php',
                'results'  => 'results.html',
                'about'    => 'about.html',
                'servers'  => 'servers.html',
                'sponsors' => 'sponsors.html',
                'contact'  => 'contact.html'
        );
           
             if (isset($_GET['k']) && isset($pages[$_GET['k']]))
                {
                    include($pages[$_GET['k']]);

                    }	else {
                      include($pages['news']);
                }

?>

 

And piece of code in team.php:

<?php

$pages = array(
                'Cranx' => 'team/cranx.html',
                'team' => 'team.php',
        );
           
             if (isset($_GET['id']) && isset($pages[$_GET['id']]))
                {
                    include($pages[$_GET['id']]);

                    }		

?>

 

Please can you tell me how I can fix this and give me some advices please :) Thank you!

Link to comment
Share on other sites

Still not working, something is still wrong.

 

Warning: main(team.php?id=) [function.main]: failed to open stream: No such file or directory in /root/web/index.php on line 122

 

Warning: main(team.php?id=) [function.main]: failed to open stream: No such file or directory in /root/web/index.php on line 122

 

Warning: main() [function.include]: Failed opening 'team.php?id=' for inclusion (include_path='.:') in /root/web/index.php on line 122

 

Line 122 is exactly:

 

include($pages[$_GET['k']]."?id=".$_GET['id']);

Link to comment
Share on other sites

at my old highschool they use a dynamic include they called it there content box they moved to asp so i snatched there old homepage and tryed to get it working i dont know if it will help but this is the code they used for theirs

 

<?php if (isset($section2) && $section2 != "") 
{ include("/Inetpub/wwwroot/test1".$section2."".$page.".php");} 
else 
{$number = "2"; include 'announcements/show_news.php';} ?>

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.