The only way to reliably delete specific rows from a database, is to have a unique property (id) for each row. Names are not necessarily unique. Worse, you may have double entries. If you try to delete a double of a row by user name using the name as identifier for the row, for example, that will result in both rows to be deleted. Not what you want.
Deleting a row by ID is easy:
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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.