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!
Deleting some entries, automatically with new input?
Moderator: General Moderators
-
phpnewbie3
- Forum Newbie
- Posts: 17
- Joined: Sat Sep 20, 2008 10:15 am
- Location: NJ, USA
Re: Deleting some entries, automatically with new input?
Why do you need that? Please, explain what you are trying to implement in real world.
There are 10 types of people in this world, those who understand binary and those who don't
-
phpnewbie3
- Forum Newbie
- Posts: 17
- Joined: Sat Sep 20, 2008 10:15 am
- Location: NJ, USA
Re: Deleting some entries, automatically with new input?
I have a site with sports-betting picks.VladSun wrote:Why do you need that? Please, explain what you are trying to implement in real world.
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?
Do you think that they delete the rows instead of showing the last 21 ones only 
There are 10 types of people in this world, those who understand binary and those who don't
-
phpnewbie3
- Forum Newbie
- Posts: 17
- Joined: Sat Sep 20, 2008 10:15 am
- Location: NJ, USA
Re: Deleting some entries, automatically with new input?
Not because of this.VladSun wrote:Do you think that they delete the rows instead of showing the last 21 ones only
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.
-
phpnewbie3
- Forum Newbie
- Posts: 17
- Joined: Sat Sep 20, 2008 10:15 am
- Location: NJ, USA
Re: Deleting some entries, automatically with new input?
Nobody with a solution?
I thought this is a fairly simple thing to do for someone who's advanced in PHP...
Oh well...
I thought this is a fairly simple thing to do for someone who's advanced in PHP...
Oh well...
- andyhoneycutt
- Forum Contributor
- Posts: 468
- Joined: Wed Aug 27, 2008 10:02 am
- Location: Idaho Falls
Re: Deleting some entries, automatically with new input?
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.
-
phpnewbie3
- Forum Newbie
- Posts: 17
- Joined: Sat Sep 20, 2008 10:15 am
- Location: NJ, USA