Jump to content

Help with handling multiple values in one $_GET variable


ASK83

Recommended Posts

I'm sending multiple values to one $_GET variable but cannot seem to be able to separate each one out to handle every option.  What I'm doing is using checkboxes, each sending an "ID" value to the $_GET collection so if multiple boxes are checked I'd have a URL ending somewhat like this... "...&id=1,2,3,4"  Now I'm trying to separate each value out do use each individual id on the next display.

Like so:

 

$get = $_GET['id'];
$each = explode(",",$get);

foreach($each as $id){
echo $id; //this will loop through each id...
}

//Or if you know how much will always be passed.
echo $each[0]; //will echo 1
echo "<br>".$each[1]; //will echo 2

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.