verdrm Posted March 22, 2008 Share Posted March 22, 2008 I need to insert POSTED values from radio buttons into MySQL. The problem is that I dynamically generate the names of the radio buttons on my form page. Ex: $qid = 1 to start <?php echo "<input name=\"$qid\" type=\"radio\" value=\"$response\" />" ?> My code is this: $qid starts at one but increases each loop foreach($_POST[$qid] as $value) { mysql_query("INSERT INTO `results` (answer) VALUES (".$value."')"); } Does anyone know how I can have DYNAMIC radio buttons with names 1,2,3, etc. and then insert them into the database? On my INSERT page, I can successfully echo the selections of the radio buttons but it won't work that way in the foreach loop. Link to comment https://forums.phpfreaks.com/topic/97390-foreach-loop/ Share on other sites More sharing options...
verdrm Posted March 22, 2008 Author Share Posted March 22, 2008 Topic solved, I didn't need the foreach loop. Link to comment https://forums.phpfreaks.com/topic/97390-foreach-loop/#findComment-498358 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.