Reputation: 2470
am using the code below to loop and delete records from database. Please i will like to count the number of rows deleted as the code loops. any idea will be appreciated
$post_ids = intval($_POST['post_id']);
foreach($post_ids as $id){
// Delete record
// I will sanitize for sql injection attack later
$query = "DELETE FROM posts WHERE id=".$id;
mysqli_query($con,$query);
}
Upvotes: 0
Views: 230
Reputation: 76639
just delete them all at once and then call $deleted = mysqli_affected_rows($con);
see the documentation.
Upvotes: 1