kleistad Posted April 17, 2007 Share Posted April 17, 2007 Hello everybody! I´ve just started learning PHP, an now i have a question. im using my index.php file as the "main" page, and when you press a link i just want the page to include another file in one of the table windows, how do I do this? I knew ASP before and rember something about "query string", can someone give me the code in PHP? thanks Quote Link to comment Share on other sites More sharing options...
btherl Posted April 17, 2007 Share Posted April 17, 2007 I'm a bit confused by your terminology. By "table window", do you mean a particular table in the html, such as a large table in the center of the page? An example of a website which does what you want would help. Quote Link to comment Share on other sites More sharing options...
Glyde Posted April 17, 2007 Share Posted April 17, 2007 The equivalent of the Request.QueryString function in ASP is the $_GET variable in PHP. $_GET is used to access the querystring paramters, example: On index.php?page=mypage, the following script: <?php print $_GET['page']; ?> Would print "mypage". Other than that I am unaware of your question. Quote Link to comment Share on other sites More sharing options...
kleistad Posted April 17, 2007 Author Share Posted April 17, 2007 youre a genius! thanks Quote Link to comment Share on other sites More sharing options...
kleistad Posted April 17, 2007 Author Share Posted April 17, 2007 hehe, ofcourse that only ansvered half my question:P now i want to add a function that imagine looks something like this: if $_get=("contact") include("contact.php") was that understandable? if you go here: http://www.zendurl.com/kleistad/mondayrock/index.php you´ll probably understand what i want to do! Quote Link to comment Share on other sites More sharing options...
Glyde Posted April 17, 2007 Share Posted April 17, 2007 Try this one: <?php $validPages = array( 'main' => 'pagetoload.php', 'press' => 'press.php', 'about' => 'about.php', 'music' => 'music.php', 'contact' => 'contact.php' ); $page = isset($_GET['page']) && in_array($_GET['page'], $validPages) ? strtolower($_GET['page']) : 'main'; include $validPages[$page]; ?> Quote Link to comment Share on other sites More sharing options...
kleistad Posted April 17, 2007 Author Share Posted April 17, 2007 <?php $validPages = array( 'main' => 'main.php', 'press' => 'press.php', 'about' => 'about.php', 'music' => 'music.php', 'contact' => 'contact.php' ); $page = isset($_GET['page']) && in_array($_GET['page'], $validPages) ? strtolower($_GET['page']) : 'main'; include $validPages[$page]; ?> i´ve done like this, but no matter what link I press, it will only load main.php... know why? Quote Link to comment Share on other sites More sharing options...
Glyde Posted April 17, 2007 Share Posted April 17, 2007 I apologize, it should be: <?php $validPages = array( 'main' => 'main.php', 'press' => 'press.php', 'about' => 'about.php', 'music' => 'music.php', 'contact' => 'contact.php' ); $page = isset($_GET['page']) && array_key_exists(strtolower($_GET['page']), $validPages) ? strtolower($_GET['page']) : 'main'; include $validPages[$page]; ?> Quote Link to comment Share on other sites More sharing options...
kleistad Posted April 17, 2007 Author Share Posted April 17, 2007 thank you, now its all where i want it Quote Link to comment 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.