• PHP Help General Help
  • [RESOLVED] How to autmatically delete the oldest row from phpmyadmin once a certain number is re

Hi guys. I need to know how to automatically delete the oldest row from a phpmyadmin database table, once a certain number of rows is reached.

I have this client who I am building website for.

He owns a magazine and he wants me to build the website for the magazine.

Furthermore, he wants me to build an application which will allow him to upload news posts, giving the website visitor a summary of the latest magazine.

He is most likely going to be uploading a news post summary once each fortnight.

Now getting to my question.

He only wants a maximum of 100 posts shown at once.

What I want to know is: how would I automatically delete the oldest row from the database once it is no longer within the most recent 100 posts?

Paul.

    Rather than deleting them, since that is not easily reversed, I'd recommend putting a limit on the query that retrieves stories, something like...

    SELECT blah, blah, blah
    FROM your_table
    ORDER BY article_timestamp DESC
    LIMIT 100
    
      NogDog;11062909 wrote:

      Rather than deleting them, since that is not easily reversed, I'd recommend putting a limit on the query that retrieves stories, something like...

      SELECT blah, blah, blah
      FROM your_table
      ORDER BY article_timestamp DESC
      LIMIT 100
      

      Very much this.

        Gonna throw in my support here as well for what it's worth - don't delete data. Memory is cheap and databases are fast.

          maxxd;11062921 wrote:

          Memory is cheap

          and disk is cheaper ... (although with SSD the lines are getting pretty blurry, methinks...)

            Write a Reply...