Page 1 of 1

How to process form with variable number of radio groups

Posted: Sat Sep 20, 2008 11:51 am
by jeremycod
Hi,

I have a question about how to process data from the form I have created. The form could contain a variable number of Web sites, and each site could contain a variable number of web pages. I use yes/no radio button for each page, and one submit button for the page. The user should be able to vote for some pages, and he can leave some pages without vote. I need to process those data on the other PHP page, so I need the information about which page he did vote for, how did he vote (yes or no) and which site that page belongs to.

Thanks
Zoran

Re: How to process form with variable number of radio groups

Posted: Sat Sep 20, 2008 6:15 pm
by josh
<input type="text" name="array[]" />
<input type="text" name="array[]" />
<input type="text" name="array[]" />
.... and so on

<?php print_r( $_REQUEST ) ?>

http://www.php.net/foreach

Re: How to process form with variable number of radio groups

Posted: Sun Sep 21, 2008 4:33 am
by jeremycod
Hi,

I thought about using multidimensional array instead, but I didn't found how to post it, so instead I have used two array (similar as you indicated). The first array keeps data about how many pages has each web site, and the other one keeps the rating values for each page. Then I use the number of pages on each site and use it to get appropriate number of pages. It is not the happiest solution but it works.
If anybody knows if it is possible use multidimensional array in $_POST, please send me some suggestion.

Thanks,
Zoran

Re: How to process form with variable number of radio groups

Posted: Sun Sep 21, 2008 2:57 pm
by josh
jeremycod wrote:If anybody knows if it is possible use multidimensional array in $_POST, please send me some suggestion.
If you want to know if its possible, try it?