Only 5 records pr. user?!?! [SOLVED]
Posted: Mon Mar 31, 2008 4:18 pm
I want to delete a record for a specific user if the user have over 5 records in my DB table... Lets say that a user is inserting he's sixt record I want the script to delete the oldest record for that user... Is that possible??? I have tryid this but it doesnt delete the records... It just inserts the new one:
Hope somebody have a answer...
Code: Select all
$query=mysql_query("SELECT * FROM oak_listen WHERE SpillerID=1");
if(mysql_num_rows($query) > 4)
{
mysql_query("DELETE * FROM oak_listen WHERE Dato IN(SELECT Dato FROM oak_listen ORDER BY Dato LIMIT 1)");
}