lworks Posted October 2, 2006 Share Posted October 2, 2006 I was wondering how to do something like this: tutorials.php?section=1&page=2 using a switch. I can get this: tutorials.php?section=1. Just don't know how to get the page part. Any help would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/22723-easy-navigation-and-_get/ Share on other sites More sharing options...
ToonMariner Posted October 2, 2006 Share Posted October 2, 2006 in your script use $_GET['section'] to get section and $_GET['page'] to grab the value of page Link to comment https://forums.phpfreaks.com/topic/22723-easy-navigation-and-_get/#findComment-102191 Share on other sites More sharing options...
lworks Posted October 2, 2006 Author Share Posted October 2, 2006 Yea..some guy told me the same thing on an IRC channel. I still don't understand how to use it in a switch. Link to comment https://forums.phpfreaks.com/topic/22723-easy-navigation-and-_get/#findComment-102194 Share on other sites More sharing options...
JasonLewis Posted October 2, 2006 Share Posted October 2, 2006 you could go like this to define them:[code]if(!isset($_GET['section'])){ $section = 1; }else{ $section = $_GET['section']; }if(!isset($_GET['page'])){ $page = 1; }else{ $page = $_GET['page']; }switch($section){//add other casescase 'default':something here}[/code]then you can do the page you would do use in each section in your sql query's. Link to comment https://forums.phpfreaks.com/topic/22723-easy-navigation-and-_get/#findComment-102196 Share on other sites More sharing options...
wildteen88 Posted October 2, 2006 Share Posted October 2, 2006 Example:[code=php:0]switch($_GET['section']){ case 1: // do stufff for section 1 break; case 2: // do stufff for section 2 break; // other cases here // defualt case: default: // do something here if $_GET['section'] doesnt match any of the cases break;}[/code] Link to comment https://forums.phpfreaks.com/topic/22723-easy-navigation-and-_get/#findComment-102199 Share on other sites More sharing options...
JasonLewis Posted October 2, 2006 Share Posted October 2, 2006 note that you don't have to use the break; for the default case. Link to comment https://forums.phpfreaks.com/topic/22723-easy-navigation-and-_get/#findComment-102203 Share on other sites More sharing options...
lworks Posted October 2, 2006 Author Share Posted October 2, 2006 Actually, like if someone goes here: tutorals.php?section=1&page=2 .. now section 1 would be /tutorials/html/basics and page 2 would be /tutorials/html/basics-page-2.php. I don't understand how to get the page=2 into the URL..[sub]if(!isset($_GET['section'])) {$section = 1; }else {$section = $_GET['section']; }if(!isset($_GET['page'])) { $page = 1; }else {$page = $_GET['page']; }switch($section){case '1':include_once("/tutorials/html/basics/basics-THEPAGENUMBER.php");break;blah blah}[/sub] Link to comment https://forums.phpfreaks.com/topic/22723-easy-navigation-and-_get/#findComment-102204 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.