Posted by Tyrone Slothrop on 02/01/06 16:17
On Wed, 1 Feb 2006 14:20:33 +0100, "Leszek" <leszekt80@poczta.onet.pl>
wrote:
>I have a form with 5 dropdown lists I want to put all selected values to an
>array called $data[] so i wrote sometthing like this:
>
>for(i=0;i<5;i++){
>echo"<select name=\"\$data[]\">";
>echo"<option value=\"1\">1</option>";
>echo"<option value=\"1\">2</option>";
>echo"<option value=\"1\">3</option>";
>echo"</select>";
>}
>
>So I think this will put all selected values into an array.
>But the problem is that when user submits the form this array goes to $_POST
>array
>And I have no idea how to read a value from an array $data which is into
>array $_POST and use it as a part of "if" statement
>
>for example
>if (value_from_array==5){
>// instructions
>}
>
>Thanks for help
>Leszek
>
When debugging POST's I usually use a print_r() to display the results
on the next page:
<pre>
<?=print_r($_POST)?>
</pre>
You may find this useful.
Your data field can be accessed this way:
$_POST['data']
And you can loop through it:
foreach ($_POST['data'] as $value) {
if ($value == 5) {...}
}
Navigation:
[Reply to this message]
|