How to delete multiple rows from mysql database with checkbox using PHP?

后端 未结 4 840
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-16 22:25

I try to delete my data in \"admin\" database, but the delete button does not function.

This is my top part



        
4条回答
  •  北荒
    北荒 (楼主)
    2021-01-16 23:09

    $sql = "SELECT * FROM blacklist";
    $result = $link->query($sql);
    $count=mysqli_num_rows($result);
    
    if ($result->num_rows > 0) {
     while($row = $result->fetch_assoc()) 
    {
    echo "";
    echo "";
    echo    "";
    echo    "";
    echo    "";
    echo    "";
    echo "";
    echo "
    "; echo "" . "ID: " . $row["id"]."" . " Dial Target: " . $row["dial_target"]."" . " Destination: " . $row["pozn"]."" . " Date: " . $row["block_date"] . "" . "
    " . "
    " . "" ."
    " . "
    " . "
    "; echo "
    "; } } else { echo "0 results"; } if(isset($_POST['Delete'])) { for($i=0;$i<$count;$i++) { $del_id = $checkbox[$i]; $del = "DELETE FROM blacklist WHERE Delete='$del_id'"; $result = $link->query($del); } if($result) { echo ""; } }

提交回复
热议问题