How to process form with variable number of radio groups

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jeremycod
Forum Newbie
Posts: 6
Joined: Mon Feb 18, 2008 4:34 pm

How to process form with variable number of radio groups

Post 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
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

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

Post 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
jeremycod
Forum Newbie
Posts: 6
Joined: Mon Feb 18, 2008 4:34 pm

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

Post 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
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

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

Post 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?
Post Reply