PHP MySqli删除错误消息

This code does delete a record from the table correctly but the second time run on the same table it still reports "Record deleted successfully". Why is that?

 // sql to delet a record
$sql = "DELETE FROM setidata WHERE  SETIData_ID=834";
if (mysqli_query($conn, $sql)) {
    echo "Record deleted successfully";
} else {
    echo "Error deleting record: " . mysqli_error($conn);
}
mysqli_close($conn);
echo "<br> Finished";
?>

Because mysqli_query($conn, $sql) is returning true since since there were no errors triggered by the query or in the function mysqli_query(). If you want to do something redundant, mysqli_query() will not stop you.

Because mysqli_query returns true not matter if the record exists or not. use mysqli_affected_rows(); to see how many rows have been deleted.

 if(mysqli_affected_rows($conn)==0){
        print "Nothing done";
    }

As per your code If query is succesful then it will echo as opted. You can run this query in phpmyadmin->SQL. First time it will show deleted rows 1. Next time it will show 0.