Page 1 of 1
Deleting some entries, automatically with new input?
Posted: Thu Nov 13, 2008 9:25 am
by phpnewbie3
Hi,
I have a MySQL database, PHP input (with PHPMyAdmin).
Can someone give me help on what is the code for when I input a new row in a table, then automatically delete the oldest entries (or entry), so for example always just the last 21 entries are kept in the table (plus the newest entry).
I have the first column in the table "timestamp" set on "ON UPDATE CURRENT_TIMESTAMP" attribute.
Thanks!
Re: Deleting some entries, automatically with new input?
Posted: Thu Nov 13, 2008 4:21 pm
by VladSun
Why do you need that? Please, explain what you are trying to implement in real world.
Re: Deleting some entries, automatically with new input?
Posted: Thu Nov 13, 2008 4:42 pm
by phpnewbie3
VladSun wrote:Why do you need that? Please, explain what you are trying to implement in real world.
I have a site with sports-betting picks.
Different people are submitting daily picks.
I want to have an accessible record of the last 21 days of their inputs plus the newest one.
Right now is that way that before every new input they click a "delete button", which cleans all the previous entries.
So only the very last input is kept in the database.
Example input interface:
http://profitsportspicks.com/test/input.html
And the example final output:
http://profitsportspicks.com/test/picks.php
In this example I do not have a timestamp in the first column, but I have in another test database.
Re: Deleting some entries, automatically with new input?
Posted: Fri Nov 14, 2008 5:16 pm
by VladSun
Do you think that they delete the rows instead of showing the last 21 ones only

Re: Deleting some entries, automatically with new input?
Posted: Fri Nov 14, 2008 5:40 pm
by phpnewbie3
VladSun wrote:Do you think that they delete the rows instead of showing the last 21 ones only

Not because of this.
The newest entry should be seen anyways, but only on the day the picks are valid for.
That is how it is set up right now.
People can access the output pages by using a password and username, because those pages are individually protected, for all the handicappers.
But I want to also keep in the databases the last 21 days of entries, so anyone can look at those with a different output form. I will use search here.
Re: Deleting some entries, automatically with new input?
Posted: Wed Nov 19, 2008 4:29 pm
by phpnewbie3
Re: Deleting some entries, automatically with new input?
Posted: Wed Nov 19, 2008 5:10 pm
by andyhoneycutt
just schedule a cron task to delete out entries older than 21 days every morning. i wouldn't leave this up to your end-users.
Re: Deleting some entries, automatically with new input?
Posted: Wed Nov 19, 2008 9:02 pm
by phpnewbie3
.