Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 17th, 2006, 03:33 PM
XXL XXL is offline
Authorized User
 
Join Date: Dec 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Auto delete by date

Hello everybody,
I'm pretty much a noobie to php and mysql :)
I'm trying to figure out how to auto delete all adds records from a db table after 30 days have passed for example

Any help is appreciated

 
Old March 29th, 2006, 01:32 AM
Authorized User
 
Join Date: Mar 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

SELECT uid,uname,
    day(bdate) as dayn,
    month(bdate) as mthn
FROM birth
WHERE month(bdate)=month(now())
AND day(bdate)
BETWEEN day(now())
AND day(now())+7

The Select statement above is a piece of php script, it select userid,user name,birth date from birth table with condition that date range should be today's date and seven more days (that is birth date falling with in week)
 "birth" table is :-
+------+-----------+------------+
| uid | uname | bdate |
+------+-----------+------------+
| 101 | sameer | 1976-09-11 |
| 102 | Bir | 1976-01-14 |
| 103 | Milind | 1976-10-24 |
| 104 | shekhar | 1987-02-18 |
| 1 | today | 2006-03-27 |
| 2 | today | 2006-03-27 |
| 105 | Neena | 2006-03-19 |
| 3 | tomorrow | 2006-03-20 |
| 4 | tomorrow | 2006-03-22 |
| 5 | range out | 2006-03-30 |
+------+-----------+------------+
10 rows in set (0.11 sec)

All you have to do is, replace select with proper delete along with condition and decide how to set the job done either by shell script and procedure or from php or any other way.

Hope it may help you.

Regards
Milind






Similar Threads
Thread Thread Starter Forum Replies Last Post
ACCESS : Auto incrementing date rashidaa Access 2 November 21st, 2007 08:36 AM
how to auto generate date? okboy SQL Server 2000 3 December 12th, 2006 08:17 PM
Auto Refresh and Auto Delete deontae45 VB.NET 2002/2003 Basics 1 September 29th, 2006 04:53 PM
asp/sql auto email on specified date keyvanjan Classic ASP Professional 2 March 5th, 2006 09:14 PM
asp/sql auto email on specified date keyvanjan Classic ASP Databases 0 February 26th, 2006 03:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.