monkeytooth Posted February 4, 2009 Share Posted February 4, 2009 Ayy, hate when I stump myself, and I am probably putting to much thought into the concept. So anyone wanna throw me a bone help me out? I have a dynamically generated list pulled via PHP from mySQL so the info is never the same as the database is for ever expanding. Anyway, listed out onto the page I want to give myself the ability to mass delete entries, so im figuring something along the concept of checkboxes next to all that is listed from there check off the ones I want deleted and hit the magic button to delete them. Now Im almost positive I can get it to do everything I want it to do minus one factor.. I cant wrap my mind around making the array of checkboxes checked. any suggestions? Link to comment https://forums.phpfreaks.com/topic/143808-doh-got-stuck-checkboxes-and-dynamic-arrays-help/ Share on other sites More sharing options...
flyhoney Posted February 4, 2009 Share Posted February 4, 2009 In what way do you mean, 'checked'? You want them to display pre-checked? Or do you want a 'Select All' option? Link to comment https://forums.phpfreaks.com/topic/143808-doh-got-stuck-checkboxes-and-dynamic-arrays-help/#findComment-754580 Share on other sites More sharing options...
monkeytooth Posted February 5, 2009 Author Share Posted February 5, 2009 sorry for the delay in response ended up having to take off... What im trying to do, well have done to one extent or another is.. from my database pull a list of stuff out for display. with this results i want a check box next to each one, which making that physically happen no problem. The purpose of the check boxes however is so that I can check off specific items from the display and where upon checking them if I hit the "Delete" button.. It will create an array out of the check boxes checked and then I can cycle that through a while loop or something to delete/update the entries in the database. The part I'm having issues wrapping my head around is.. how do I create this array of information given off the check boxes checked. As the data is never consistent as the DB is constantly growing. The only consistent thing I may have about this concept is to display 25 or 50 results per page. That aside I need to get my "emIDn" value (its a column on the table im working with..) and place that into said array if the check box is checked. So I am open to suggestions :-) Link to comment https://forums.phpfreaks.com/topic/143808-doh-got-stuck-checkboxes-and-dynamic-arrays-help/#findComment-755166 Share on other sites More sharing options...
flyhoney Posted February 5, 2009 Share Posted February 5, 2009 So just display each item from the database like so, with the ID of the item as the value: <input type="checkbox" name="emIDn[]" value="1" />First Thing <input type="checkbox" name="emIDn[]" value="2" />Second Thing <input type="checkbox" name="emIDn[]" value="3" />Third Thing And the code to process this would look something like this: if (isset($_POST['delete'])) { foreach ($_POST['emIDn'] as $emIDn) { $query = "DELETE FROM table WHERE emIDn = " . mysql_real_escape_string($emIDn); mysql_query($query); } } Link to comment https://forums.phpfreaks.com/topic/143808-doh-got-stuck-checkboxes-and-dynamic-arrays-help/#findComment-755294 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.