Forum Moderators: coopster

Message Too Old, No Replies

Multiple Delete from a list of records

         

AndyD

8:50 pm on Jun 18, 2004 (gmt 0)

10+ Year Member



If I have a list of records from a database on the screen, each with a check box beside them, how would I delete all the records that have been ticked?

I assume I would use a variable similar to checked[], but not sure what syntax I would use to remove them from the database?

Would I loop round each record comparing the checked[] value and it it's set, delete the record?

Cheers,

Andrew

jatar_k

8:58 pm on Jun 18, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



syntax could be

delete from tablename where id in (1,2,5,8,34,65)

you could build the string for all the checked rows in a loop and then put it into the query and do the query once it is done looping through the values.

AndyD

11:36 pm on Jun 21, 2004 (gmt 0)

10+ Year Member



Jatar_K, Thanks once again for your wonderful advice. The example code you gave me works a treat. Just took me an hour+ to work out the correct syntax ;)

Cheers, and keep up the good work.

Andrew