Re: $_POST variable

From: Date: Fri, 11 Mar 2011 19:43:27 +0000
Subject: Re: $_POST variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-311779@lists.php.net to get a copy of this message
Hi Danny, On Friday, March 11, 2011, 7:28:10 PM, you wrote: > 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 You could use foreach to iterate through the post variables until you encounter a match: foreach ($_POST as $key => $value){ if (substr($key, 0, 6) == "radio_") { $buttonName = $key; $buttonValue = 4value; break 2; } } I haven't tried the above code, but I hope someone will correct my efforts if I'm wrong. -- Geoff Lane Cornwall, UK

« previous php.general (#311779) next »