Jump to content

Easy Navigation and $_GET.


lworks

Recommended Posts

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
Share on other sites

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 cases

case '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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.