Hello, I would like to add a little feature to my site that I can just click a button and then add a row to mysql. But I want a maximum of 20 rows, and when the 21st is submitted the oldest one gets removed. How do I do this? Thanks
Well you don't have to delete them if you don't want. When calling on the table just limit it to the latest 20 entries. If you want to have them deleted then use mysql_num_rows to get the number of rows and delete accordingly.
Yeah, Just wondering if there was a faster way than counting then delteing by date. And yes, i want to delete, not just limit
set the id autoincrement in DB. Then try this: $s = "insert into table_1........."; // to insert new row $r = mysql_fetch_array(mysql_query("select min(id) from table_1")); // to find out the oldest row $s = $r[0]; $d = "delete from table_1 where id = $s"; // to delete the row Hope it will work