Forum Moderators: coopster

Message Too Old, No Replies

QueryString Problem!

         

MaticooL

12:43 pm on Jan 12, 2006 (gmt 0)

10+ Year Member



Hello!
I have a problem with QueryString!
I know how to add one variable to querystring, but I dont know how to add multiple, I use the code below and the link becomes:

www.example.com/emulator.php?=GBA

but I dont know how to make it go like:

www.example.com/emulator.php?=GBA&letter=B

(code I use)

<?php
include('header.inc');

$page = $_GET['page'];

switch ($page) {
case 'GBA':
include('gba.inc');
break;

default:
include('main.inc');
break;
}

include('footer.inc');

?>

Please tell me what do I need to add to this code to get second variable

Thanks in advance!

dreamcatcher

1:46 pm on Jan 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi MaticooL, welcome to Webmaster World. :)

The problem is the $page variable isn`t populating because you haven`t specified it.

Try:

www.example.com/emulator.php?page=GBA&letter=B
www.example.com/emulator.php?page=GBA

dc

MaticooL

2:07 pm on Jan 12, 2006 (gmt 0)

10+ Year Member



You probably did not understand. I meant that I dont know HOW to ADD MORE VARIABLES to querystring.
For example, I know how to make querystring with one variable like www.example.com/index.php?page=1 but I dont know how to add second variable to make it also like www.example.com/index.php?page=1&color=red.

Understand?

dreamcatcher

3:17 pm on Jan 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, using your original example if letter is also present, add it to the switch.

www.example.com/emulator.php?=GBA&letter=B

<?php
include('header.inc');

$page = $_GET['page'];

switch ($page) {
case 'GBA':

if (isset($_GET['letter']))
{
$letter = $_GET['letter'];
//do something
}

include('gba.inc');
break;

default:
include('main.inc');
break;
}

include('footer.inc');

?>

Does that help? You can have a switch inside a switch if you want.

dc

MaticooL

3:53 pm on Jan 12, 2006 (gmt 0)

10+ Year Member



Ok, but what is //do something?
And what will be the link at the end?
I am so confused...
Where do I put the letters like A,B,C ... etc?

dreamcatcher

4:14 pm on Jan 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I was basically saying that when you process, do something. ;) Sounds like you might want to read up a little on PHP, as you seem a little confused here.

Another option is a switch inside a switch:

www.example.com/emulator.php?=GBA&letter=B

(code I use)

<?php
include('header.inc');

$page = $_GET['page'];

switch ($page) {
case 'GBA':

if (isset($_GET['letter']))
{

switch ($_GET['letter'])
{
case "A":
//code here
break;

case "B":
//code here
break;
}

}

include('gba.inc');
break;

default:
include('main.inc');
break;
}

include('footer.inc');

?>

etc etc

dc

MaticooL

4:24 pm on Jan 12, 2006 (gmt 0)

10+ Year Member



Wow, Thanks Dude! But it seems that when I go to?page=GBA&letter=A or B, whatever, it also includes the GBA.inc file....why?