zgkhoo Posted October 7, 2007 Share Posted October 7, 2007 http://www.phpfreaks.com/forums/index.php?action=search <---redirect to search page http://www.phpfreaks.com/forums/index.php?action=profile <--redirect to profile page http://www.phpfreaks.com/forums/index.php?action=calender <---redirect to calender page now i only know how to design php page by using eg...search.php /profile.php /calender.php and i wanna learn the above method.. may i know how to write this method and this method called wat? thanks.... Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted October 7, 2007 Share Posted October 7, 2007 use a switch statement on your index.php page, like this: <?php switch ($_GET['page']) { default: case "home": require_once ("lib/home.php"); break; case "progress": require_once ("lib/progress.php"); break; case "support": require_once ("lib/support.php"); break; } and put all the files that you require_once in a lib folder to keep it organized Regards ACE Quote Link to comment Share on other sites More sharing options...
zgkhoo Posted October 7, 2007 Author Share Posted October 7, 2007 wat it called? no name? how abt this one http://chinese2.cari.com.my/myforum/viewsub.php?gid=184 why this one using ?gid= while another using ?action= Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted October 7, 2007 Share Posted October 7, 2007 nope not really, just call it a "Switch Statement" Regards ACE Quote Link to comment Share on other sites More sharing options...
zgkhoo Posted October 7, 2007 Author Share Posted October 7, 2007 how abt this one? http://chinese2.cari.com.my/myforum/viewsub.php?gid=184 why this one using ?gid= while another using ?action= Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted October 7, 2007 Share Posted October 7, 2007 it all depends on what the script does, when you start getting different URL's like that its most likely the result of a database query or something like that. Do a search on Google and look at Google's URL. Quote Link to comment Share on other sites More sharing options...
zgkhoo Posted October 7, 2007 Author Share Posted October 7, 2007 sorry i really a newbie, wat should i type in google search box for research this ? thank you very much Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted October 7, 2007 Share Posted October 7, 2007 lol, I meant type anything into google, and look at what Google's URL is after you have pressed the "search" button. Quote Link to comment Share on other sites More sharing options...
logicopinion Posted October 7, 2007 Share Posted October 7, 2007 $action= &$_REQUEST['action']; if (!file_exists("navi/".$action.".php")) { include "body.php"; next;} else { if (isset($action) && $action!='body') { include "navi/".$action.".php"; } else { include "body.php"; }} i`d use something like this.. Quote Link to comment Share on other sites More sharing options...
zgkhoo Posted October 7, 2007 Author Share Posted October 7, 2007 lol, I meant type anything into google, and look at what Google's URL is after you have pressed the "search" button. oic google contains ?hl= and ?q= wat is the different between this two? and how abt this one Quote Link to comment Share on other sites More sharing options...
zgkhoo Posted October 7, 2007 Author Share Posted October 7, 2007 and how abt this one http://www.talkphp.com/showthread.php?p=1804#post1804 wat is the #post1804 meant? thanks again. Quote Link to comment Share on other sites More sharing options...
zgkhoo Posted October 9, 2007 Author Share Posted October 9, 2007 anyone know abt it? Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted October 9, 2007 Share Posted October 9, 2007 #post1804 or something like this is usually a HTML Anchor the pound sign is usually used in a query string as a anchor; so that the query string will take the end user to a specific point in the page were the anchor is at. Quote Link to comment Share on other sites More sharing options...
Aureole Posted October 9, 2007 Share Posted October 9, 2007 Ok if you're willing to listen I'll explain it... <?php switch ($_GET['page']) { case "home"; pageHome(); break; case "contact"; pageContact(); break; case "support"; pageSupport(); break; default: pageHome(); break; } function pageHome() { echo('I am the Homepage!'); } function pageContact() { echo('I am the Contact Page'); } function pageSupport() { echo('I am the Support Page'); } ?> Look at the above code... switch ($_GET['page']) { ...is the part we're looking at...that means that it will be index.php?page= If we change that to... switch ($_GET['section']) { ...then the link would instead be index.php?section= Ok now the next part we're looking at is: case "home"; pageHome(); break; So if you type ?page=home it will run the function pageHome() which I made: function pageHome() { echo('I am the Homepage!'); } For every page you have, you'll have an instance of this code: case "home"; pageHome(); break; Say if you wanted to use the code I posted but add a "pictures" page, you'd add this: case "pictures"; pagePictures(); break; And this: function pagePictures() { // Code to show your Pictures here... } ... default: pageHome(); break; that just tells the page what to do if you type index.php or index.php?page, so if you don't supply it with a page to go to it will go to the one you specify as "default". That make sense...? Quote Link to comment Share on other sites More sharing options...
zgkhoo Posted October 9, 2007 Author Share Posted October 9, 2007 wow, cool tutorial.....very clear...lolz. got it.. thanks again.. Quote Link to comment Share on other sites More sharing options...
Aureole Posted October 9, 2007 Share Posted October 9, 2007 No problem at all. 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.