I think that should work but I have no guarantee.
Code:
// First get the number of rows you have
$slavesel = mysql_query("SELECT * FROM slaves");
$result = mysql_num_rows($slavesel);
$randomdel = rand(2,$result); // Select your random amount of rows to delete
$limit_top = $result; // Set your upper limit
// The first row to delete is selected randomly
$limit1 = rand(0,$limit_top);
// If the amount of rows to delete added to the first limit exceeds the upper limit, set the upper limit as the last row to delete
if ($limit1 + $randomdel > $limit_top) {
$limit2 = $limit_top;
}
else {
$limit2 = $limit1 + $randomdel;
}
// Then proceed to deletion
$delete = mysql_query("DELETE FROM slaves LIMIT '$limit1','$limit2'");
PLEASE NOTE
I'm not sure but I think this line should be changed since MySQL begins counting at zero, but I'd like to have someone else confirm.
Code:
$limit_top = $result; // Set your upper limit
Code:
$limit_top = $result - 1; // Set your upper limit