Jump to content

Get values from multiple selects


starfleetrp

Recommended Posts

I am can not seem to find a way to do this, I have been looking for half and hour (partially that I do not know what to look for)

What I have is a form that has a bunch of select boxs (all with a different name, actually an ID number from the database)

What I want to do is be able to loop though all of the submitted data from each one and analyize it.  This would be no problem if I knew the names of all of the select boxs, but I dont.
Link to comment
https://forums.phpfreaks.com/topic/30714-get-values-from-multiple-selects/
Share on other sites

How are they named?

If there's something about them that will differentiate them from other fields you could use the following.  You can loop through ALL the fields (post or get method).

Look through all fields if posted using GET method:
[code]
<?php
foreach ($_GET as $field => $value){
  echo "<br />Field Name:  " . $field . " - Value:  " . $value";
}
?>
[/code]
Look through all fields if posted using POST method:
[code]
<?php
foreach ($_POST as $field => $value){
  echo "<br />Field Name:  " . $field . " - Value:  " . $value";
}
?>
[/code]

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.