DELETE FROM users WHERE id=?
As for more than one row, databases start to digress. Some give you the option to use IN(1,2,3)... but personally, I'd just delete them one by one in a loop. It's not like that would take such a long time: typically a small query will execute in a few milliseconds.
As you didn't say what kind of interface you're using, I can't go into much more details. In a HTML form you typically use the same name for every checkbox, and the id as the value. Then, for every checked checkbox, you'll get a parameter checkboxname=rowid. It's easy to loop through those. | [reply] [d/l] [select] |
- Get the values of the checked checkboxes (How you do that depends on what type of checkboxes they are. Tk? HTML via CGI? You didn't say.)
- Prepare an SQL statement that deletes one entry (determined by a bind variable). (Assuming you are using an SQL database, you didn't say.).
- Loop over the values you have, executing the SQL query (with the current value) each time.
| [reply] |
Or use one of the HTML::DBForm variants (as far as I can see HTML::DBForm doesn't do checkboxes, only radio buttons, tables or dropdown lists), which can provide this for you.
HTH.
Walking the road to enlightenment... I found a penguin and a camel on the way.....
Fancy a yourname@perl.me.uk? Just ask!!!
| [reply] |
Hi,
you can get the list of users from the DB.
Display the users and make sure that your checkbox value should identify the user_id ( may be whatever u can identify your user as unique ).When multiple users are selected,then in the CGI you can get it (user ids )in the array-context .If your db supports sub-query then, you just do,
delete from tbl_name where id in (join(',',@usr_id_array));
Oterwise, you just prepare a delete query (outside the loop )and execute the query in the for loop for each user id.
This will delete all the users from the db.
-kulls.
| [reply] [d/l] |
| [reply] |