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 Link to comment https://forums.phpfreaks.com/topic/47324-new-to-php/ 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. Link to comment https://forums.phpfreaks.com/topic/47324-new-to-php/#findComment-230874 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. Link to comment https://forums.phpfreaks.com/topic/47324-new-to-php/#findComment-230883 Share on other sites More sharing options...
kleistad Posted April 17, 2007 Author Share Posted April 17, 2007 youre a genius! thanks Link to comment https://forums.phpfreaks.com/topic/47324-new-to-php/#findComment-230886 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! Link to comment https://forums.phpfreaks.com/topic/47324-new-to-php/#findComment-230890 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]; ?> Link to comment https://forums.phpfreaks.com/topic/47324-new-to-php/#findComment-230902 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? Link to comment https://forums.phpfreaks.com/topic/47324-new-to-php/#findComment-230906 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]; ?> Link to comment https://forums.phpfreaks.com/topic/47324-new-to-php/#findComment-230908 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 Link to comment https://forums.phpfreaks.com/topic/47324-new-to-php/#findComment-230927 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.