View Full Version : Auto deletion of data in my database
01-14-2004, 01:11 PM
i'm doing a webpage using php codings. i need help in the auto deletion of my data from my database.
For example i have an announcement to announce today and end tomorrow and by tomorrow i want the announcement to be deleted from the database. how do i aoto delete the data from my database? And scripts to help me? i'm still using the old php and mysql. pls help. its urgent. Thanks!
Dependes on what you call autodeletion. I suppose it's removing the records, from the table). mySQL sadly doesn't support stored procedures so you need to invoke a script that does the deleting. The delting itself is simple.
$del="DELETE FROM table WHERE DATEDIFF(datevariable, Now()) >= 1"
$result=mysql_query($del) or die('Querysproblem')
(replace bold with your actual names. inside the table, you need a variablke with the date on which this record is supposed to be displayed)
But you need to automatically run this script each day (at 00:00:00 hour) with a CRON-job or a Scheduled Task (depending on the platform you are on.
Or you can just click a link each few days to remove these records if you want to have some level of control over it (i don't immedeately see the need to do this daily, since you can just select on the displaydate and leave all past messages inthere till the end of the month/year or so)
01-15-2004, 01:58 AM
hi sorry to bother again.
i'm new to php therefore i need the full script. or just by writing the 2 lines you had given to me then i just insert it into the scheduled task and it will run? sorry to bother.
01-15-2004, 02:00 AM
And do i need to put in any connection codes? sorry to bother again. thanks!
01-15-2004, 03:23 AM
i've run the application and has convert it into .exe file but when i run the command prompt prompt me the following error:
The NTVDM CPU has encountered an illegal instructions.
CS:0e10 IP:0217 OP:63 61 6c68 6 f
What does this mean?
Thanks for helping. sorry to bother again.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.