Skip to main content
Inspiring
January 11, 2007
Question

delete multiple records

  • January 11, 2007
  • 8 replies
  • 822 views
I need to delete muliple records from a table called leag_leagues. I made a form on the first page and set the value of the checkboc to the value of my id for my table. I then want to pass it to the delete page where it deletes the record and redirects to the delete record complete page. I am using PHP and mySQL.
Any help would be appriciated.
This topic has been closed for replies.

8 replies

Inspiring
March 14, 2007
Jansolo wrote:
> any chance you could elaborate - sorry I am new to PHP (use to use cfmx -
> trying to save on hosting costs). I have looked up loads on loops but seem to
> be missing the key to it all.

Without knowing what it is that you're trying to do, it's rather
difficult. All I know is that you want to delete some images. Where are
they? What sort of scenario are you talking about?

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Participating Frequently
March 14, 2007
any chance you could elaborate - sorry I am new to PHP (use to use cfmx - trying to save on hosting costs). I have looked up loads on loops but seem to be missing the key to it all.

I really appreciate the help.
Inspiring
March 14, 2007
Jansolo wrote:
> what if there are multiple records to delete? I have used the above example, how would i get each image and then delete each in turn?

Use a loop.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Participating Frequently
March 14, 2007
hi there,

what if there are multiple records to delete? I have used the above example, how would i get each image and then delete each in turn?
Inspiring
March 14, 2007
On Wed, 14 Mar 2007 11:14:08 +0000 (UTC), "Jansolo"
<webforumsuser@macromedia.com> wrote:

>also how would you delete all the images deleted with a multiple delete?

Get all the images associated with the record you want to delete and
use unlink.

http://hk.php.net/unlink
--
Steve Fleischer
steve at flyingtigerwebdesign dot com
Hong Kong
Participating Frequently
March 14, 2007
also how would you delete all the images deleted with a multiple delete?
Participating Frequently
March 14, 2007
could you post the problem you had and solved?
Inspiring
January 11, 2007

"justin wendorf" <webforumsuser@macromedia.com> wrote in message
news:eo63mh$o11$1@forums.macromedia.com...
>I need to delete muliple records from a table called leag_leagues. I made a
> form on the first page and set the value of the checkboc to the value of
> my id
> for my table. I then want to pass it to the delete page where it deletes
> the
> record and redirects to the delete record complete page. I am using PHP
> and
> mySQL.
> Any help would be appriciated.
>

Name your checkboxes the same, using array notation, and put the record id
in the checkbox:

<input type="checkbox" name="blah[]" value="<?php echo
$row_recordset1['recordid'];?>">

Then, delete them using an if statement to check for hte form field:

if(isset($_POST["blah"])) {
$delete = implode(",",$_POST["blah"]);
$query = sprintf("DELETE FROM mytable WHERE recordid IN (%s)",$delete);

execute your query and redirect
}

Tom Muck
http://www.tom-muck.com


Inspiring
January 12, 2007
I get this error on the delete page
Warning: implode() [function.implode]: Bad arguments. in /home/jewuypq/public_html/srlanes/admin/deleteleagueconfirm.php on line 10