iChriss Posted January 21, 2011 Share Posted January 21, 2011 Hello everyone I am coding a membership system for my usersystem on my website and I needed a little help. I have searched around quite a bit and can't find a working code. In my database I have the date the VIP was purchased and I was wondering if anyone had a code which would check if they've had VIP for over a month and if so, delete it from the database. I'm new-ish to MySQL and PHP and can't seem to code a working one. Link to comment https://forums.phpfreaks.com/topic/225150-delete-row-after-1-month/ Share on other sites More sharing options...
litebearer Posted January 21, 2011 Share Posted January 21, 2011 name of field and type? Link to comment https://forums.phpfreaks.com/topic/225150-delete-row-after-1-month/#findComment-1162898 Share on other sites More sharing options...
iChriss Posted January 21, 2011 Author Share Posted January 21, 2011 username (The user's username) rank ( 1= Normal User 2= VIP) vip_purchased (The date the VIP was purchased, preferably in the format: Y/m/d) They are all VARCHAR but I can change/add anything if needed So I want the rank to change back to 1 after a month has passed since vip_purchased Link to comment https://forums.phpfreaks.com/topic/225150-delete-row-after-1-month/#findComment-1162994 Share on other sites More sharing options...
Valakai Posted January 21, 2011 Share Posted January 21, 2011 I would store the vip_purchased as an int(10) and populate it with the time() function at the time of purchase You can then check when 1 month has passed with this code // (time() - $vip_purchased) - Number of seconds since time of purchase // (60*60*24*31) - Number of seconds in 31 days if(((time() - $vip_purchased) > (60*60*24*31)) { // VIP Time Expired } Link to comment https://forums.phpfreaks.com/topic/225150-delete-row-after-1-month/#findComment-1163002 Share on other sites More sharing options...
Valakai Posted January 21, 2011 Share Posted January 21, 2011 If you want to keep the format Y/m/d, you can use the date() function on the $vip_purchased timestamp. Link to comment https://forums.phpfreaks.com/topic/225150-delete-row-after-1-month/#findComment-1163006 Share on other sites More sharing options...
litebearer Posted January 21, 2011 Share Posted January 21, 2011 I would suggest using datetime for your date field, much easier to do comparisons, search upon and format output. Link to comment https://forums.phpfreaks.com/topic/225150-delete-row-after-1-month/#findComment-1163013 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.