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 Quote Link to comment 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>'; } ?> Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
deezy Posted May 28, 2008 Author Share Posted May 28, 2008 managed to get it working, cheers! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.