cheechm Posted May 6, 2007 Share Posted May 6, 2007 Hi, I am trying to show a different pages using this script: <?php switch($id) { default: include('filename.php'); break; case "1": include('filename1.php'); break; case "2": include('filename2.php'); break; case "3": include('filename3.php'); break; case "4": include('filename4.php'); break; case "5": include('filename5.php'); break; case "6": include('filename6.php'); break; case "7": include('filename7.php'); } ?> But whenever I try for instance http://mysite.com/filename.php?id=1 I always end up with the contents of filename.php, not filename1.php . Quote Link to comment https://forums.phpfreaks.com/topic/50265-solved-showing-a-page/ Share on other sites More sharing options...
clown[NOR] Posted May 6, 2007 Share Posted May 6, 2007 have you used $id = $_GET['id']? <?php $id = $_GET['id']; switch($id) { default: include('filename.php'); break; case "1": include('filename1.php'); break; case "2": include('filename2.php'); break; case "3": include('filename3.php'); break; case "4": include('filename4.php'); break; case "5": include('filename5.php'); break; case "6": include('filename6.php'); break; case "7": include('filename7.php'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/50265-solved-showing-a-page/#findComment-246732 Share on other sites More sharing options...
cheechm Posted May 6, 2007 Author Share Posted May 6, 2007 When I put that in, it means that nothing is shown. Quote Link to comment https://forums.phpfreaks.com/topic/50265-solved-showing-a-page/#findComment-246737 Share on other sites More sharing options...
clown[NOR] Posted May 6, 2007 Share Posted May 6, 2007 you need to use $_GET['id'] to get whatever comes after ?id= in the url Quote Link to comment https://forums.phpfreaks.com/topic/50265-solved-showing-a-page/#findComment-246744 Share on other sites More sharing options...
cheechm Posted May 6, 2007 Author Share Posted May 6, 2007 link=topic=139487.msg592248#msg592248 date=1178480030] you need to use $_GET['id'] to get whatever comes after ?id= in the url Ok, so the number comes after the ?id= . And that number means include the file. But it never does. All I ever get is the default. Quote Link to comment https://forums.phpfreaks.com/topic/50265-solved-showing-a-page/#findComment-246749 Share on other sites More sharing options...
clown[NOR] Posted May 6, 2007 Share Posted May 6, 2007 hmm.. then I dont know sorry Quote Link to comment https://forums.phpfreaks.com/topic/50265-solved-showing-a-page/#findComment-246751 Share on other sites More sharing options...
MadTechie Posted May 6, 2007 Share Posted May 6, 2007 can you do the following please print_r($_GET); and post the results, as what clown[NOR] is saying is 100% correct Quote Link to comment https://forums.phpfreaks.com/topic/50265-solved-showing-a-page/#findComment-246756 Share on other sites More sharing options...
cheechm Posted May 6, 2007 Author Share Posted May 6, 2007 Actually works now. Just needed to restart my Firefox. Dunno why it did that. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/50265-solved-showing-a-page/#findComment-246761 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.