Results 1 to 3 of 3

Thread: deleting multiple files

  1. #1

    Thread Starter
    Lively Member sridharao's Avatar
    Join Date
    Feb 2007
    Posts
    106

    deleting multiple files

    While deleting multiple files, I often come across with statements where single statement is executed for every record. It is like displaying a check box to the user and then deleting using the following code:
    PHP Code:
    if($delete){
    for(
    $i=0;$i<$count;$i++){
    $del_id $checkbox[$i];
    $sql "DELETE FROM $tbl_name WHERE id='$del_id'";
    $result mysql_query($sql);


    I have a list of ID's in a string which I must delete at once. Is this query legal in mysql?

    PHP Code:
    $string "12, 34, 45, 36, 14, 67, 89";
    $query "DELETE FROM mytable  WHERE mytable.ID IN ($string)"
    mysql_query($query) or die(mysql_error()); 
    Save trees, avoid plastics, say no to zoo, go veg, recycle as much, live holistic

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: deleting multiple files

    I don't see why it wouldn't work.

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: deleting multiple files

    No problems and it is much more efficient than executing a separate query for every item.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width