Re: $_POST variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/12/2011 10:37 AM, tedd wrote:
> At 9:28 PM +0200 3/11/11, Danny wrote:
>> Hi guys,
>>
>> I have a form that has a long list of radio-bottons inside of it. The
>> radio-buttons are dynamically created via php and MySQL.
>>
>> Here is an example of one of the radio buttons:
>>
>> <input type="radio" name="<?php print ("radio_".$result_from_mysql) ;
>> ?>" value="0">
>> <input type="radio" name="<?php print ("radio_".$result_from_mysql) ;
>> ?>" value="1">
>>
>> Now, when I submit this form to another page for processing, how would
>> I "catch"
>> the above radio-button's $_POST name since I do not know the name,
>> only that it
>> starts with "radio_" ?
>>
>> Thank You
>>
>> Danny
> 
> 
> Danny:
> 
> Replace <?php print ("radio_".$result_from_mysql) ; ?> with an option[]
> array.
> 
> Realize that the name of the radio input stays the same -- it is the
> value that changes.
> 
> Here's a demo:
> 
> http://php1.net/b/form-radio1/
> 
> Don't make it more complicated than it needs be.
> 
> Cheers,
> 
> tedd
> 

My point exactly!  So long as the name of the name[] part is the same
they will be treated as the same "group" of radio buttons.

So here is the long and short; if the name is the same and you specify
an index then names with the same index will be grouped together:
name[1] and name[1] are the same but different group from name[2].  If
you don't specify an index, but the name is the same, then they are
grouped together:  name[], name[].

By grouped together I mean that only one of the group can be selected
and therefore successful on submit.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux