Jump to content

Delete MySQL data at a certain time?


verdrm

Recommended Posts

I am building a lunch ordering system for a company. The employees can login, order lunch, and the administrator can see what everyone ordered for lunch in the admin panel. The problem is that when the employees enter data, it stays in the database until they update it. If an employee is sick, their lunch order from the previous day is still in the database.

 

Is there a way to clear those values they enter at a certain time in MySQL or does anyone have a suggestion as to how to clear the data after the lunch hour each day?

Link to comment
Share on other sites

I had thought about Scheduled Tasks already, but it isn't running on my own servers, it is a "portable" script.

 

I assume I would just add the DELETE FROM code onto the main page, that way when a user logs in it would delete their old order and they can repost a new order?

 

Is my thinking correct?

Link to comment
Share on other sites

Yh u can do that but then itll delete lunch theyve ordered a minute ago (maybe).

There is something you can do tho. If your using cpanel then their should already be a cron thing in the cpanel. Tell the cron to run a script every 24 hours (or every day).

Link to comment
Share on other sites

You could be looking at the problem the wrong way. You don't need to delete anything, you just need to show orders from today.

 

select * from lunch_order
where lunch_order.ordertime>[begining of today]
and lunch_order.ordertime<[now()/end of today]

 

This would then allow you to keep employees orders and find out over information from the data at a later date (like, how much your spending to feed each employee ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.