You can refer to the following articlehttps:///article/
SQL:$SQL="delete from `doing` where id in ('1,2,3,4')";
Data are separated by commas.
Form:
<form action="?action=doing" method="post">
<input name="ID_Dele[]" type="checkbox" value="1"/>
<input name="ID_Dele[]" type="checkbox" value="2"/>
<input name="ID_Dele[]" type="checkbox" value="3"/>
<input name="ID_Dele[]" type="checkbox" value="4"/>
<input type="submit"/>
</form>
OK $ID_Dele=$_POST['ID_Dele'] will be an array. Although PHP is of weak type, there is no weak ASP here.
ASP can:
SQL="delete from [doing] where id in ('"&ID_Dele&"')" to delete. But PHP cannot put $ID_Dele directly in. Because $ID_Dele is not '1,2,3,4', because $ID_Dele is an array with keys and values.
OK, it's not difficult in PHP. There is a function: implode(), right. A function that is exactly the opposite of split() exploit() function, the latter two are divided by a certain character (such as a comma), while the former can be spliced into a string.
therefore:
$ID_Dele= implode(",",$_POST['ID_Dele']);
$SQL="delete from `doing` where id in ($ID_Dele)";
I provide the test code:
<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 "After merge:".$ID_Dele."<br />Before merge:";
if($del_id!=""){
$del_num=count($del_id);
for($i=0;$i<$del_num;$i++){
echo $del_id[$i];
}
}
}else{
echo "Please submit";
}
?>
<form action="?action=doing" method="post">
<input name="ID_Dele[]" type="checkbox" value="1st"/>1st
<input name="ID_Dele[]" type="checkbox" value="2nd"/>2nd
<input name="ID_Dele[]" type="checkbox" value="3rd"/>3rd
<input name="ID_Dele[]" type="checkbox" value="4th"/>4th
<input type="submit"/>
</form>
SQL:$SQL="delete from `doing` where id in ('1,2,3,4')";
Data are separated by commas.
Form:
Copy the codeThe code is as follows:
<form action="?action=doing" method="post">
<input name="ID_Dele[]" type="checkbox" value="1"/>
<input name="ID_Dele[]" type="checkbox" value="2"/>
<input name="ID_Dele[]" type="checkbox" value="3"/>
<input name="ID_Dele[]" type="checkbox" value="4"/>
<input type="submit"/>
</form>
OK $ID_Dele=$_POST['ID_Dele'] will be an array. Although PHP is of weak type, there is no weak ASP here.
ASP can:
SQL="delete from [doing] where id in ('"&ID_Dele&"')" to delete. But PHP cannot put $ID_Dele directly in. Because $ID_Dele is not '1,2,3,4', because $ID_Dele is an array with keys and values.
OK, it's not difficult in PHP. There is a function: implode(), right. A function that is exactly the opposite of split() exploit() function, the latter two are divided by a certain character (such as a comma), while the former can be spliced into a string.
therefore:
Copy the codeThe code is as follows:
$ID_Dele= implode(",",$_POST['ID_Dele']);
$SQL="delete from `doing` where id in ($ID_Dele)";
I provide the test code:
Copy the 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 "After merge:".$ID_Dele."<br />Before merge:";
if($del_id!=""){
$del_num=count($del_id);
for($i=0;$i<$del_num;$i++){
echo $del_id[$i];
}
}
}else{
echo "Please submit";
}
?>
<form action="?action=doing" method="post">
<input name="ID_Dele[]" type="checkbox" value="1st"/>1st
<input name="ID_Dele[]" type="checkbox" value="2nd"/>2nd
<input name="ID_Dele[]" type="checkbox" value="3rd"/>3rd
<input name="ID_Dele[]" type="checkbox" value="4th"/>4th
<input type="submit"/>
</form>