HI my code is no longer functioning to limit the amount of lines in SQL it should limit 300 its 900
$result = OpenPDO($conn,"SELECT COUNT(`datetime`) FROM `played_songs` ORDER BY `datetime` ASC",$_query,"");
$row = $result->fetch();
$n = $row["COUNT(`datetime`)"] - 300;
if ($n > 1) {
$q = OpenPDO($conn,"SELECT `datetime` FROM `played_songs` ORDER BY `datetime` ASC",$_query,"");
while ($n) {
$r = $q->fetch();
$id = $r["datetime"];
OpenPDO($conn,"DELETE FROM `played_songs` WHERE `datetime`=?" ,$_execute,$id);
$n--;
}