mcfmullen Posted December 20, 2010 Share Posted December 20, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/222174-_get-array/ Share on other sites More sharing options...
trq Posted December 20, 2010 Share Posted December 20, 2010 Now the thing is, I want to $_GET all this information, store it into a variable array and then manipulate it. $_GET already is an array. I'm not sure what the rest of your question is. Quote Link to comment https://forums.phpfreaks.com/topic/222174-_get-array/#findComment-1149424 Share on other sites More sharing options...
mcfmullen Posted December 21, 2010 Author Share Posted December 21, 2010 How can I use the information? does $variable = $_GET[] claim everyting there or is the method different? .. or is it simply not necessary to restore the $_GET or $_POST? Quote Link to comment https://forums.phpfreaks.com/topic/222174-_get-array/#findComment-1149704 Share on other sites More sharing options...
trq Posted December 21, 2010 Share Posted December 21, 2010 $_GET is just like any other array. Quote Link to comment https://forums.phpfreaks.com/topic/222174-_get-array/#findComment-1149705 Share on other sites More sharing options...
sasa Posted December 21, 2010 Share Posted December 21, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/222174-_get-array/#findComment-1149769 Share on other sites More sharing options...
mcfmullen Posted December 23, 2010 Author Share Posted December 23, 2010 It works. Thank you so much! Quote Link to comment https://forums.phpfreaks.com/topic/222174-_get-array/#findComment-1150598 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.