dear friends,
hello
I'm in a problem and i need your help , I'm having a page in which there is a table and table contains multiple row in each row there are two colum one having a checkbox and another have a image and after this I have a image for delete option at last of the table, My problem is to delete all the image selected with the chechkbox I'm having the image ID in value part of the check box so plz help with the query
thanks with regards
Sachin
delete records from database
Moderator: General Moderators
Code: Select all
for ($i=0;$i<sizeof($CHECKBOX_VALUE);$i++);
$query = mysql_query("DELETE FROM !<TABLE>! WHERE Image_ID='".$CHECKBOX_VALUE[$i]."'");- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
I'm more a fan of doing it all in one hit:
Code: Select all
$sql = 'DELETE FROM table_name WHERE image_id IN (''' . implode(''',''',$_POST['checkbox_name']) . ''')';
mysql_query($sql) or die(mysql_error());
echo myslq_affected_rows() . ' records deleted, of ' . sizeof($_POST['checkbox']) . ' submitted.';