Jump to content


Photo

multiple items in 1 $_get


  • Please log in to reply
5 replies to this topic

#1 Infected-Waffle

Infected-Waffle
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 08 May 2006 - 07:18 PM

Is there a way to store multiple variables in 1 $_GET['']?

edit: what I mean is, is there a way to make something like:
whatever.php/something.php?d0=var1, var2

kind of like an array in the url

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 08 May 2006 - 07:28 PM

You can pass arrays, yes. Like if you have a bunch of checkboxes, just name them like this: mycheckboxes[]

Then in your processing:

foreach($_GET['mycheckboxes'] as $key)
   echo "$key<br>";

Info: PHP Manual


#3 Infected-Waffle

Infected-Waffle
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 08 May 2006 - 07:32 PM

It's not check box's. It's like if you click a link it adds it to the url var and keeps it until you end the game (whihc is what this is for.) I need a way to force link colors to change during one game session, so I decided to store the used options in the url and call them from there and add them each time you visit a page.

[a href=\"http://www.infected-designs.com/jeopardy/\" target=\"_blank\"]http://www.infected-designs.com/jeopardy/[/a]

it's for that, you'll understand when you look at one of the boards.

edit:

here's the source if you need it...
[a href=\"http://www.infected-designs.com/jeopardy/source/\" target=\"_blank\"]http://www.infected-designs.com/jeopardy/source/[/a]

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 08 May 2006 - 07:47 PM

Yes you can place an array within an array in a ur. Something like this:
<?php

if(isset($_GET['say']))
{
    echo '<pre>' . print_r($_GET['say'], true) . '</pre>';
}

?>
<a href="?say['hello']=hello&say['world']=world">Set the array in the url!</a>


#5 Infected-Waffle

Infected-Waffle
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 08 May 2006 - 07:51 PM

[!--quoteo(post=372387:date=May 8 2006, 03:47 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ May 8 2006, 03:47 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Yes you can place an array within an array in a ur. Something like this:
<?php

if(isset($_GET['say']))
{
    echo '<pre>' . print_r($_GET['say'], true) . '</pre>';
}

?>
<a href="?say['hello']=hello&say['world']=world">Set the array in the url!</a>
[/quote]
I'm confused. Could you please explain more?

#6 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 08 May 2006 - 09:33 PM

Basically say['hello'] is an array

say is the primary array ($_GET['say']) to get the bits in the [] after say you use $_GET['say']['hello'];

You are just setting an array within the url.

The print_r function in the code supplied shows the contents of the $_GET['say'] array.

I haveing arrays within a URL isn't most pleasent thing to see as can become confusing.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users