I am programming something like e-mail f开发者_运维知识库or my users. I want to allow people to select letters and delete selected. How can I do it? I can't imagine how can I do it only with one MySQL query. Is it even possible?
If by "select" and "delete" you mean the SQL commands SELECT
and DELETE
, then you don't need to SELECT and DELETE at the same time. First run a SELECT to display the emails and to allow the user to choose which emails they want to delete. Then use the ids of the emails (usually a hidden field) to run a DELETE with a WHERE id IN (..., ..., ...)
.
DELETE $table_name WHERE id in ($ids)
should do your delete. in one shot. so you jsut need to get all the id's for the records which im assuming are somehow coded into your html as part of the id, class, or value attributes for whatever elements..
It takes one query to list their email, but once you get a list of unique ids that the user has selected, you can run one delete query per email.
精彩评论