所以基本上我要做的是让以下代码返回它在echo中删除的条目数量。
$sql6 = "DELETE FROM Already_Selected WHERE LastUpdated < NOW() - INTERVAL 5 DAY7";
if ($conn->query($sql6) === TRUE) {
echo "Records older than 5 days have been deleted!";
} else {
echo "<br> 0 Records to delete";
}
}
所以目前输出
已删除超过5天的记录
我真的希望它返回
已删除5行
例如
答案 0 :(得分:1)
它将存储在数据库对象的affected_rows
属性中。然后,像这样,例如:
$deleted_qty = $conn->affected_rows;
否则(程序式):
$deleted_qty = mysqli_affected_rows($conn);
答案 1 :(得分:0)
特别针对您的问题,您可以替换
echo "Records older than 5 days have been deleted!";
与
printf(" %d\n number of row(s) have been deleted",mysql_affected_rows($conn));