kadamsurekha Posted March 28, 2007 Share Posted March 28, 2007 hello! i have a checkbox array of some unknown size.its a dynamic array created. i want to know out of all checkboxes how many r selected and which are they? and then insert the data in the table based on that. i hav written the code as follows:- <? $no=0; $friendname= $_POST['friendname']; $storecount=$_POST['storeid']; while($no<$storecount) { if($friendname[$no]) { $sql = "INSERT INTO groupfriends (groupid, username) VALUES ('$stid[$no]', '$friendname[$no]')"; $result = mysql_query($sql) or die('Query failed. ' . mysql_error()); } $no=$no+1; } ?> i dont think this will work.it will add all the checkoxes data to the table. i want to insert only of those which r selected. can any1 help me?????????? thx n regards Link to comment https://forums.phpfreaks.com/topic/44669-checkbox-in-php/ Share on other sites More sharing options...
Trium918 Posted March 28, 2007 Share Posted March 28, 2007 Where is the code for your check boxes? Link to comment https://forums.phpfreaks.com/topic/44669-checkbox-in-php/#findComment-216901 Share on other sites More sharing options...
boo_lolly Posted March 28, 2007 Share Posted March 28, 2007 we have to know what's going on to be able to help you. what is the purpose of storeid? what is it used for? is it a checkbox form or is it a dropdown menu? what? and to answer your question, the checkboxes will not be stored in the array unless they were checked to begin with. so you're checkbox array will not store values that were not checked. Link to comment https://forums.phpfreaks.com/topic/44669-checkbox-in-php/#findComment-216930 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.