Jump to content

$_GET array?


mcfmullen

Recommended Posts

I have the following code in parser.php:

 

<?php

$xml = simplexml_load_file('differences.xml');

$object = $xml->xpath('//item');

$count = count($object);

$i = 0;

echo "<form method='get' action='parsed.php'>";

while($i < $count)
{

$objectname = $object[$i]['name'];
echo "<input type='checkbox' name='option".$i."' value='$objectname' checked>".$objectname;
echo "<br>";

$i++;

}

echo "<br><input type='submit' value='Proceed'><br>";
echo "</form>";
?>

 

This passes a url as such:

http://localhost/parsed.php?option0=dog&option1=cat&option2=fish

 

Now the thing is, I want to $_GET all this information, store it into a variable array and then manipulate it.

 

Essentially, parser.php displays a checklist of items inside differences.xml. The user can then choose what items to select or deselect in the form. Upon sending the form, parsed.php will display the full contents of XML data relating to the selected items. The user can then modify these items, and save them to the MySQL database.

 

Right now, I just need help to get parsed.php to display the names of all the objects passed into the form (see url).

 

This brings me back to my original question: how to store it into an array?

 

This way I can count the objects in the array, run a loop through the XML where items match the values in the array and so on.

 

Any help?

Link to comment
Share on other sites

change

echo "<input type='checkbox' name='option".$i."' value='$objectname' checked>".$objectname;

to

echo "<input type='checkbox' name='option[".$i."]' value='$objectname' checked='checked'>".$objectname;

and in $_GET['option'] is array of checked object

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.