deezy Posted May 28, 2008 Share Posted May 28, 2008 Hello I have a repeating table with a checkbox at the end of each row. The checkboxes are dynamically assigned a different name: <input type="checkbox" name="checkbox" id="<? echo $row_details['id']; ?>" value="<? echo $row_details['id']; ?>" Upon submission of the form how can i go through the checkboxes and for each checked item i need to order them like (id1,id3,id7,id9) and store the whole string into my database? thanks for any help Link to comment https://forums.phpfreaks.com/topic/107552-solved-store-all-selected-checkbox-ids/ Share on other sites More sharing options...
pocobueno1388 Posted May 28, 2008 Share Posted May 28, 2008 The HTML should be like this <input type="checkbox" name="checked[]" id="<? echo $row_details['id']; ?>" value="<? echo $row_details['id']; ?>" I changed the name to checked[]. That will be the array all the ID's are stored in. Now to get all the values, just use a foreach loop: <?php foreach ($_POST['checked'] as $id){ echo $id.'<br>'; } ?> Link to comment https://forums.phpfreaks.com/topic/107552-solved-store-all-selected-checkbox-ids/#findComment-551311 Share on other sites More sharing options...
deezy Posted May 28, 2008 Author Share Posted May 28, 2008 thanks, that works really well. Is there a way i can get each 'id' and store them as id1,id6,id8,id9 ? thanks again. Link to comment https://forums.phpfreaks.com/topic/107552-solved-store-all-selected-checkbox-ids/#findComment-551350 Share on other sites More sharing options...
deezy Posted May 28, 2008 Author Share Posted May 28, 2008 managed to get it working, cheers! Link to comment https://forums.phpfreaks.com/topic/107552-solved-store-all-selected-checkbox-ids/#findComment-551377 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.