|
Posted by onembk on 08/29/06 23:56
On 2006-08-29 15:24:02 -0600, kurrent@gmail.com said:
> I am relatively new to PHP and just have a question regarding $_POST to
> get a value passed via a form to be included of the parameter of an
> array I am using:
>
> eg.
>
> <?
>
> $a array = ("1", "2", "3");
>
> echo "<form method=POST>
>
> <select name=b size=1>
> <option value=1>number1</option>
> <option value=2>number2</option>
> <option value=0>number3</option>
> </select>
>
> <input type=submit name=Submit>
>
>
> </form>";
>
> echo "$a[$b]";
>
>
> Since I have a global variables turned off, and would like to keep
> learning with them off, I am stumped on to get that value passed
>
>
>> From my understanding, I see that $_POST[b] would successfully retrive
> the value of the $b variable. So i've tried many variants on the syntax
> but no luck (e.g. "$a[$_POST[b]]) etc...
>
> any help is much appreciated :) thanks!
You need to either
echo $a[$_POST['b']];
or
$b = $_POST['b'];
echo $a[$b];
(the b is in quotes).
Navigation:
[Reply to this message]
|