freelancer Posted February 1, 2007 Share Posted February 1, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/ Share on other sites More sharing options...
Balmung-San Posted February 1, 2007 Share Posted February 1, 2007 You would need to pass on the id in the include. For example: <?php if(isset($_GET['k']) && isset($pages[$_GET['k']])) { if(strcmp($_GET['k'], 'team') == 0) { include($pages[$_GET['k']]."?id=".$_GET['id']); } else { ... } } ?> At least that's how I'd understand it to work. Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/#findComment-174784 Share on other sites More sharing options...
freelancer Posted February 1, 2007 Author Share Posted February 1, 2007 I can't find any way how does this help Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/#findComment-174822 Share on other sites More sharing options...
Balmung-San Posted February 1, 2007 Share Posted February 1, 2007 When you include team.php it doesn't get the $_GET['id'] variable passed to it if you just include team.php. The code I presented above does an include on team.php?id=$_GET['id'], so team.php will see the $_GET['id']. Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/#findComment-174832 Share on other sites More sharing options...
freelancer Posted February 1, 2007 Author Share Posted February 1, 2007 But to witch file I should put this phrase. I've tried so many that its going too complicated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/#findComment-174838 Share on other sites More sharing options...
Balmung-San Posted February 1, 2007 Share Posted February 1, 2007 index.php Replace the include($pages[$_GET['k']]) with if(strcmp($_GET['k'], 'team') == 0) { include($pages[$_GET['k']]."?id=".$_GET['id']); } else { include($pages[$_GET['k']]); } Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/#findComment-174841 Share on other sites More sharing options...
freelancer Posted February 1, 2007 Author Share Posted February 1, 2007 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']); Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/#findComment-174854 Share on other sites More sharing options...
Balmung-San Posted February 1, 2007 Share Posted February 1, 2007 I should've noticed this. Bug in what I gave you... Replace if(strcmp($_GET['k'], 'team') == 0) With if((strcmp($_GET['k'], 'team') == 0) && isset($_GET['id'])) Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/#findComment-174858 Share on other sites More sharing options...
freelancer Posted February 1, 2007 Author Share Posted February 1, 2007 Still in trouble with that, can't get whats wrong. /--/ If I remove code from team.php and put it to index.php it includes cranx.html but above it is still error. Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/#findComment-174892 Share on other sites More sharing options...
Balmung-San Posted February 1, 2007 Share Posted February 1, 2007 So if you access index.php?k=team&id=Cranx, you still get an error? Try to access team.php?id=Cranx, does that produce an error? Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/#findComment-174894 Share on other sites More sharing options...
freelancer Posted February 1, 2007 Author Share Posted February 1, 2007 So if you access index.php?k=team&id=Cranx, you still get an error? Try to access team.php?id=Cranx, does that produce an error? This does not but there is still Team page above it. Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/#findComment-174895 Share on other sites More sharing options...
Balmung-San Posted February 1, 2007 Share Posted February 1, 2007 Do this: $pagereq = $pages[$_GET['k']]."?id=".$_GET['id']; echo $pagereq; include($pagereq); Where you had: include($pages[$_GET['k']]."?id=".$_GET['id']); Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/#findComment-174902 Share on other sites More sharing options...
freelancer Posted February 1, 2007 Author Share Posted February 1, 2007 Doesn't make any difference in my view. Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/#findComment-174919 Share on other sites More sharing options...
Balmung-San Posted February 1, 2007 Share Posted February 1, 2007 Check the source to see what $pagereq echoed out. It should either show up in the source or right on the page. Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/#findComment-174922 Share on other sites More sharing options...
freelancer Posted February 1, 2007 Author Share Posted February 1, 2007 team.php?id=Cranx it was echoed. Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/#findComment-174923 Share on other sites More sharing options...
fbrown Posted February 1, 2007 Share Posted February 1, 2007 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';} ?> Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/#findComment-174973 Share on other sites More sharing options...
fbrown Posted February 1, 2007 Share Posted February 1, 2007 i dont see were they set $section or $page thats were i got lost but if you need to see the whole source i can email it to you but thats the only block of php in there home page Quote Link to comment https://forums.phpfreaks.com/topic/36665-solved-dynamic-includes/#findComment-174977 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.