I like to know how you do this:
I have made a sort of a chatbox that automatic updates it self with a script and it loads up the latest 50 chat messages from database.
Now i wonder, how to delete messages after each 24 hours but keep the first new 50 messages and delete the older ones after that.
Is this possible with MYSQLi and PHP or must i do it with a better solution?
UPDATE
Followed advise from Lund and a fast response from my provider: I am not able to do Cron Jobs or MYSQL Events with my current plan. Also i do not have the money for upgrading it, so erm.... if there is another solution, thank you for helping me out on this matter folks.
I have a table called: chatbox and have this in it:
C_ID
chattext
name
date
You should check MYSQL Events.
You can create an Event (e.g. the delete function) an schedule it to run once a day.
MySQL Create Event docs
Pseudo code (Won't actually work without some edits to fit your code, but its an idea) - I don't know how your data is stored, or its variable names. Or your table name. Or basically any information that I would need to actually get this to work.
You can set this up to execute everytime a message is stored, or check it against the current time of the server to remove it daily.
UPDATE: THIS CODE SHOULD BE WORKING WITH YOUR CODE