You can refer to the following article http://www.jb51.net/article/6488.htm
SQL: $ SQL = "delete from 'doing' where id in ('1, 2, 3, 4 ')";
Data are separated by commas.
Form:
Copy codeThe Code is as follows:
<Form action = "? Action = doing "method =" post ">
<Input name = "ID_Dele []" type = "checkbox" id = "ID_Dele []" value = "1"/>
<Input name = "ID_Dele []" type = "checkbox" id = "ID_Dele []" value = "2"/>
<Input name = "ID_Dele []" type = "checkbox" id = "ID_Dele []" value = "3"/>
<Input name = "ID_Dele []" type = "checkbox" id = "ID_Dele []" value = "4"/>
<Input type = "submit"/>
</Form>
Good $ ID_Dele = $ _ POST ['id _ Dele '] will be an array. Although PHP is of a weak type, ASP is not weak here.
ASP can be directly:
SQL = "delete from [doing] where id in ('" & ID_Dele. However, PHP cannot directly include $ ID_Dele. Because $ ID_Dele is not '1, 2, 3, 4 ', because $ ID_Dele is an array with keys and values.
Well, it's not difficult in PHP. There's just a function: implode (), right. A function is the opposite of the split () explode () function. The latter two are separated by a certain character (such as a comma), and the former can be spliced as a string.
Therefore:
Copy codeThe Code is as follows:
$ ID_Dele = implode (",", $ _ POST ['id _ dele']);
$ SQL = "delete from 'doing' where id in ($ ID_Dele )";
The script home provides the test code:
Copy codeThe Code is as follows:
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<? Php
If ($ _ POST ["action"] = "doing "){
$ Del_id = $ _ POST ["ID_Dele"];
$ ID_Dele = implode (",", $ _ POST ['id _ dele']);
Echo "merged:". $ ID_Dele. "<br/> before merging :";
If ($ del_id! = ""){
$ Del_num = count ($ del_id );
For ($ I = 0; $ I <$ del_num; $ I ++ ){
Echo $ del_id [$ I];
}
}
} Else {
Echo "Submit ";
}
?>
<Form action = "? Action = doing "method =" post ">
<Input name = "ID_Dele []" type = "checkbox" id = "ID_Dele []" value = "1st"/> 1st
<Input name = "ID_Dele []" type = "checkbox" id = "ID_Dele []" value = "2nd"/> 2nd
<Input name = "ID_Dele []" type = "checkbox" id = "ID_Dele []" value = "3rd"/> 3rd
<Input name = "ID_Dele []" type = "checkbox" id = "ID_Dele []" value = "4th"/> 4th
<Input type = "submit"/>
</Form>