Good, I would like information on Deletion of records greater than 10. This is ...
If the database has 10, the function does not work! If the database is above 10, delete X old records until you get 10 again.
I'm using it like this ...
$stmt = $con->prepare("SELECT client_id FROM public_rewards WHERE client_id = ?");
$stmt->bind_param('s', $_SESSION['u_id']);
$stmt->execute();
$stmt->bind_result($uid);
$stmt->store_result();
if($stmt->num_rows > 5) {
while($row = $stmt->fetch()) {
$remove_favorite = "DELETE FROM public_rewards WHERE client_id = '$uid' ORDER BY DESC";
}
} else {
return false;
}
I was a bit disoriented, because this function erases EVERYTHING! And I do not want it all .. just stick with recent 10.