htetnainglynn Posted June 4, 2010 Share Posted June 4, 2010 Hi everyone, First time here and learning PHP now. I have a page which includes of several checkboxes based on a table rows. Eg, if my users table has 30 users, there're going to be 30 checkboxes. I am sure you probably hav guessed by now that if the user selected all 30 users, and delete, they all will be deleted in the database. I am having difficulties in how to uniquely identify each checkbox and get the value from each checkbox because I am thinking of storing user_id from the database in each checkbox as value. Any help would be appreciated on this. To my understanding, if one checkbox is selected and i get the value "on" or if there's value in that checkbox i get the value of it in php file but there should be some sort of like arrays to actually loop through the $_POST["inputCheckboxName"] and get selected checkbox's value or something like that ? Any help would be greatly appreciated. Thanks all. Quote Link to comment https://forums.phpfreaks.com/topic/203831-how-to-find-which-checkboxs-selected-and-get-their-values/ Share on other sites More sharing options...
htetnainglynn Posted June 4, 2010 Author Share Posted June 4, 2010 Umm I found the answer. It does return as an array and we need to declare the name of the checkbox something like name="checkboxNames[]" and retrieve it back from the php file as array For eg. for($i = 0 ; $i < count($_POST(["checkboxNames"]) ; $i++) { //do whatever we wanna do } Hope it helps others who have the same problem like me. Quote Link to comment https://forums.phpfreaks.com/topic/203831-how-to-find-which-checkboxs-selected-and-get-their-values/#findComment-1067522 Share on other sites More sharing options...
The Eagle Posted June 4, 2010 Share Posted June 4, 2010 Since your issue seems to be resolved, you can help keep the forums tidy by marking this topic solved. Quote Link to comment https://forums.phpfreaks.com/topic/203831-how-to-find-which-checkboxs-selected-and-get-their-values/#findComment-1067530 Share on other sites More sharing options...
htetnainglynn Posted June 4, 2010 Author Share Posted June 4, 2010 ahh how to do that ? Sorry if it sounds stupid, but i just can't find any button or similar to do that kinda thing. help me Quote Link to comment https://forums.phpfreaks.com/topic/203831-how-to-find-which-checkboxs-selected-and-get-their-values/#findComment-1067532 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.