shortysbest Posted September 25, 2010 Share Posted September 25, 2010 I'm not sure how to use foreach to send multiple form information to the database. <form> <input id="<?php print $row['id'];?>" name="attendance" type="radio" value="1" checked="checked" /> <input id="<?php print $row['id'];?>" name="attendance" type="radio" value="2" /> <input id="<?php print $row['id'];?>" name="attendance" type="radio" value="3" /> </form> I have a group of 3 buttons for three different options and this is in a php while loop,and there could be anywhere from 1 to 30 of these forms that ineed to send the data to the database at the same time. each one of these groups are next to a user to mark if they were present, tardy, or absent. I need it to get the id of the user for each one of these and send the value to the database as well. Link to comment https://forums.phpfreaks.com/topic/214379-php-foreach-with-radio-buttons/ Share on other sites More sharing options...
fortnox007 Posted September 25, 2010 Share Posted September 25, 2010 Your values should be retrieved from an array atleast that's what the foreach loop is for. You might try it with a while loop when you retrieve data from you database: like : <form action="#" method="postal_pigeon"> <?php $result = mysqli_query($dbc,$query)or die(mysqli_error($dbc).mysqli_errno($dbc)); while ($row = mysqli_fetch_array($result)){ echo '<input id="'.$row['id'].'>" name="attendance" type="radio" value="'.$row['value'].'" />'; } ?> </form> - I made some changes Link to comment https://forums.phpfreaks.com/topic/214379-php-foreach-with-radio-buttons/#findComment-1115589 Share on other sites More sharing options...
fortnox007 Posted September 25, 2010 Share Posted September 25, 2010 Oh i tottaly misread you question I did the complete opposite. Well it might be usefull. Let me think for a solution on the question you (do) have (soz, been late last night) Link to comment https://forums.phpfreaks.com/topic/214379-php-foreach-with-radio-buttons/#findComment-1115594 Share on other sites More sharing options...
sasa Posted September 26, 2010 Share Posted September 26, 2010 change form to <input id="<?php print $row['id'];?>" name="attendance[<?php print $row['id'];?>]" type="radio" value="1" checked="checked" /> <input id="<?php print $row['id'];?>" name="attendance[<?php print $row['id'];?>]" type="radio" value="2" /> <input id="<?php print $row['id'];?>" name="attendance[<?php print $row['id'];?>]" type="radio" value="3" /> all in one forrm Link to comment https://forums.phpfreaks.com/topic/214379-php-foreach-with-radio-buttons/#findComment-1115788 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.