HI friends ..
i have a show page which shows all the records of the users with edit delete option with each ..
now i want to add check boxes with each record & want to give user choice to delte more than 1 record with the selection of check boxes ....
means if user select with check of the checkboxes then only those records should be deleted ...
can anybody gives me any idea for this stuff ????
delete with checkboxes ??
Moderator: General Moderators
Code: Select all
<input type="checkbox" name="ids[]" value="10" /> Record with ID of 10 <br />
<input type="checkbox" name="ids[]" value="28" /> Record with ID of 28 <br />
<input type="checkbox" name="ids[]" value="32" /> Record with ID of 32 <br />
Code: Select all
// ... validate your $_POST somewhere before this
$ids = $_POST['ids'] ;
$keysToDelete = implode(',', $ids) ;
$sql = "DELETE FROM table WHERE idField IN ({$keysToDelete})" ;simple validations
just make sure there are integers, never trust user input data
Code: Select all
$ids = array();
foreach($_POST['ids] as $v)
$ids[] = intval($v);
$keysToDelete = implode(',', $ids) ;