Cep Posted November 20, 2006 Share Posted November 20, 2006 Hello,I am just wondering if anyone here could tell me how I would collect the post data from my form which has been generated by my PHP script.Basically my script runs a query to retrieve data from my table and for each row it creates a HTML table row. In the last column of this row I have a checkbox with the value set as that rows primary ID field in the table.I then want to be able to select any number of these check boxes and submit the form.As the number of rows generated is random and as the check boxes ticked can be random I need to know how I can get the data into PHP. I have tried naming every checkbox with like this name="myCheck[]" but for some reason I don't get any value at all.Any help? :) Link to comment https://forums.phpfreaks.com/topic/27884-retrieve-data-from-random-number-of-checkboxes/ Share on other sites More sharing options...
craygo Posted November 20, 2006 Share Posted November 20, 2006 some code would be good but you can try this[code]<?php$i=0;while($r=mysql_fetch_assoc($res){echo "<input type=\"checkbox\" name=\"myCheck".$i."\" value=".$r['id'].">$i++;}?>[/code]then in your script to process the form[code]<?php$ids = array();foreach($_POST as $key => $val){if(substr($key, 0, 7) == "myCheck"){$ids[] = $val; }}?>[/code]now your id's are in an array called $ids for you to use where ever you likeRay Link to comment https://forums.phpfreaks.com/topic/27884-retrieve-data-from-random-number-of-checkboxes/#findComment-127511 Share on other sites More sharing options...
Cep Posted November 21, 2006 Author Share Posted November 21, 2006 Thanks Ray, I just needed a pointer really and that looks good to me cheers! Link to comment https://forums.phpfreaks.com/topic/27884-retrieve-data-from-random-number-of-checkboxes/#findComment-127850 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.