Drezard Posted June 25, 2007 Share Posted June 25, 2007 Okay, so I want to create a one of those systems where it pulls records from the database, puts them into a table, then put a checkbox next to each record and at the bottom of the table it has a drop down box with actions like 'Delete selected records' and stuff like that. Any clue on where I could find a tutorial or some code to do this. I know how to do the 'Delete selected records' bit and the display records in a table, but i need help with the checkbox bit and which boxes are checked. Thanks, Daniel Link to comment https://forums.phpfreaks.com/topic/57022-php-checkboxes/ Share on other sites More sharing options...
sushant_d84 Posted June 25, 2007 Share Posted June 25, 2007 Well its common question.. You do one thing. Give the name serially like check1 check2 check3 to each checkbox .... and values for that checkboxes should be the primary key id for. and in post u can loop for check* where *=1,2,3,4etc.. and chek if value is posted or not. if value is posted then u can go for deleting the record. Link to comment https://forums.phpfreaks.com/topic/57022-php-checkboxes/#findComment-281926 Share on other sites More sharing options...
Jenk Posted June 25, 2007 Share Posted June 25, 2007 no, you do not do that. You create an array of checkbox values. <?php foreach ($records as $record) { echo "<input type=\"checkbox\" value=\"{$record['id']}\" name=\"check[]\"/>\n"; } ?> Then on the receiving page, you traverse the array: <?php foreach ($_POST['check'] as $checkbox) { delete_record($checkbox); } ?> after sufficient validation. Link to comment https://forums.phpfreaks.com/topic/57022-php-checkboxes/#findComment-281947 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.