Page 1 of 1

Question about form input...

Posted: Sat Jun 27, 2009 11:13 am
by Wolf_22
I have a form that basically has the following in it:

Code: Select all

echo "\t\t\t<input type=\"radio\" name=\"sols[0]\" value=\"" . $ops[$i] . "\"> " . $ops[$i] . "<br />\n";
In the above, I'm curious as to what the "name" is. To me, it looks like an array, but don't all arrays require the money sign ($) to be placed in front of them?

Re: Question about form input...

Posted: Sat Jun 27, 2009 12:01 pm
by juma929
Hello,

That is a HTML form array so you can access all elements using arrays in PHP, for example:

Code: Select all

 
<input type="text" name="item[]" value="test"/>
<input type="text" name="item[]" value="test two"/>
 
On your PHP page that retrieves the values you could then access each of those fields using arrays:

Code: Select all

 
$textfields = $_POST['item'];
 
foreach($textfields as $key => $value)
{
    echo $value . '<br/>';
}
 
 
If you need anything else let me know :).

Thanks.

Re: Question about form input...

Posted: Sat Jun 27, 2009 12:02 pm
by juma929
Hello,

Just to clarify, in HTML form arrays you dont need the dollar sign ($) :).

Thanks.

Re: Question about form input...

Posted: Sat Jun 27, 2009 3:18 pm
by Wolf_22
Thanks juma929. That cleared it up perfectly. :)

Re: Question about form input...

Posted: Sat Jun 27, 2009 3:30 pm
by juma929
No problem, as I said if you ever need any more help at all just let me know and i'll do all I can :).

Thanks :D