Re: deleting muliple feilds from a table using an array

From: Date: Fri, 24 Mar 2006 21:28:18 +0000
Subject: Re: deleting muliple feilds from a table using an array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-232564@lists.php.net to get a copy of this message
thanks all, very helpful! ----- Original Message ----- From: "Brady Mitchell" <bradym@ext.usu.edu> To: "benifactor" <snorris17@cox.net>; "php" <php-general@lists.php.net> Sent: Friday, March 24, 2006 1:21 PM Subject: RE: [PHP] deleting muliple feilds from a table using an array > -----Original Message----- > example code: > //implode the value of the submitted form > //$del will look like 38, 40, 43 > $del = implode(",", $idd); > //create query for the deletion of values from submited form > $query = "delete From news where id = '$del'"; > //execute query > mysql_query($query) or die(mysql_error()); > //echo sucess message > echo("<b><center>The Post has been deleted...</b></center>"); > > > here is what my problem is... > > This code will only delete the first value of $idd. what i > think is wrong is i have the incorrect syntax to delete > multiple feilds from a table if some one can help me it would > be greatly appreactiated. $query = "delete From news where id IN($del)"; Take a look at http://dev.mysql.com/doc/refman/5.0/en/where-optimizations.html. The user comments are helpful. Brady

« previous php.general (#232564) next »