Hi Tristan

It seems wierd to me that $math would be an array even after that you have
named all your form fields to $math.

Well, what you can do otherwise that is a very known method is naming your
fields name[].

In your case this would be math[].

If you name many of your fields this way, $_GET['math'] will be an array
with auto-filled indexes.

Example:

---submit.html---

<form action="receiver.php" method="post">
Number 1: <input type="text" name="math[]"><br>
Number 2: <input type="text" name="math[]"><br>
Number 3: <input type="text" name="math[]"><br>
<input type="submit" name="submit" value="Submit">
</form>

-------
Now let's say you enter 1 in field 1, 2 in field 2 and 3 in field 3.
Now let's send the data to receiver.php
-------

---receiver.php---

<?php

$math = $_GET['math'];

foreach($key => $value as $math){
echo "$key => $value<br>";

?>
------

This would output:

1 => 1
2 => 2
3 => 3

-------

This method can also be very useful with selects, naming the select "name[]"
Then you when you submit, name[] will become an array where the selected
indexes are given in the array.

Hope you found this helpful

Eric

"Tristan Gutsche" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello,
>
> I am having problems generating an array based on data passed from a form.
> The form has a series of fields with the same name "math". When submited
if
> i have register_globals=on i have no problems calling a $math variable and
> it spits out all the values assigned to math, however with
> register_globals=off only the last value passed in the HTTP string is
being
> returned.
>
> Any suggestions welcome.
>
> Regards
> Tristan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to