Arkane Posted November 11, 2009 Share Posted November 11, 2009 Hey guys, I've been asked to make a sort of admin system for a mysql database. Theres very little to it, but for some reason it is demanded of me. What I have just now is 2 checkboxs, and the record name displaying. The checkboxes are written from the php, and have values of "approve" and "delete", while the names of both are $sqlresult->id What I need is for them to process at the other end, so that every id with a value of "approve" will be updated, and "delete" will be deleted from the records, but I don't really have a clue how to do it. Can anyone give any pointers? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/181144-deleting-multiple-records-from-a-checkbox/ Share on other sites More sharing options...
JustLikeIcarus Posted November 12, 2009 Share Posted November 12, 2009 Give the checkboxes names of approve[] and delete[] then set their values equal to the id. Like: <input type="checkbox" name="approve[]" value="1" /> Then if its checked you will have an approve array. $approved = $_POST['approve']; foreach($approved as $id){ //do whatever } Quote Link to comment https://forums.phpfreaks.com/topic/181144-deleting-multiple-records-from-a-checkbox/#findComment-956148 Share on other sites More sharing options...
Arkane Posted November 16, 2009 Author Share Posted November 16, 2009 Hey, thanks for the reply. Unfortunately, I made a major mistake in my description. what I actually want is the ability to do this from a radio box, not a checkbox. I tried adapting the method given, but obviously it wouldn't work properly as the radios all have the same name. Is there any way to change this to work with radios? Quote Link to comment https://forums.phpfreaks.com/topic/181144-deleting-multiple-records-from-a-checkbox/#findComment-958569 Share on other sites More sharing options...
JustLikeIcarus Posted November 16, 2009 Share Posted November 16, 2009 you could name your radios as "action[$sqlresult->id]" with values of "delete" and "approve" then just do. $actions = $_POST['action']; foreach($actions as $id => $action){ if($action == 'delete') //etc ... } Quote Link to comment https://forums.phpfreaks.com/topic/181144-deleting-multiple-records-from-a-checkbox/#findComment-958572 Share on other sites More sharing options...
Arkane Posted November 16, 2009 Author Share Posted November 16, 2009 OK, thank you very much, I had no idea how to do that, it'll be perfect. Cheers mate Quote Link to comment https://forums.phpfreaks.com/topic/181144-deleting-multiple-records-from-a-checkbox/#findComment-958578 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.