champbronc2 Posted October 31, 2008 Share Posted October 31, 2008 OK, I have a column in my database labeled expiredate and it is a date column. How can I have a query that will do this: $query = mysql_query("UPDATE users SET expiredate='CURDATE()+30days', referer='$username' WHERE referer='available' SORT BY visits DESC"); Then I also need something that will do this: $query = mysql_query("UPDATE users SET referer='' WHERE expiredate is before the current date") I will pay $5 PayPal if someone can help, and give an explanation. Quote Link to comment https://forums.phpfreaks.com/topic/130897-solved-mysql-date-functions-and-adding-will-pay-for-help/ Share on other sites More sharing options...
akitchin Posted October 31, 2008 Share Posted October 31, 2008 save yourself money by learning to read manuals. you can add any amount of time to a date in DATETIME format using either DATE_ADD() or similar syntax: UPDATE users SET expiredate = NOW() + INTERVAL 30 DAY, referer-'$username' WHERE blah as for dropping the referer from the database when the expiry date has been reached, you'll need to run the query everyday (perhaps a cronjob is suitable): UPDATE users SET referer='' WHERE NOW() >= expiredate this will drop the referer from every row where the current DATETIME is past or equal to the expiry date. Quote Link to comment https://forums.phpfreaks.com/topic/130897-solved-mysql-date-functions-and-adding-will-pay-for-help/#findComment-679462 Share on other sites More sharing options...
champbronc2 Posted October 31, 2008 Author Share Posted October 31, 2008 Thanks. PM me your PayPal if you want the $5. Quote Link to comment https://forums.phpfreaks.com/topic/130897-solved-mysql-date-functions-and-adding-will-pay-for-help/#findComment-679471 Share on other sites More sharing options...
akitchin Posted October 31, 2008 Share Posted October 31, 2008 i would urge you to consider donating that $5 to phpfreaks here: http://www.phpfreaks.com/page/donations we all help for free, but we can't help (and you can't be helped) without the server running. every donation helps. EDIT: alternatively if you bump that to $10, you can be recognized with special stars. to do so, hit Profile (top navigation) > Actions > Paid subscriptions. Quote Link to comment https://forums.phpfreaks.com/topic/130897-solved-mysql-date-functions-and-adding-will-pay-for-help/#findComment-679476 Share on other sites More sharing options...
champbronc2 Posted October 31, 2008 Author Share Posted October 31, 2008 OK. Thanks for the help too. $5 donated. Quote Link to comment https://forums.phpfreaks.com/topic/130897-solved-mysql-date-functions-and-adding-will-pay-for-help/#findComment-679493 Share on other sites More sharing options...
akitchin Posted October 31, 2008 Share Posted October 31, 2008 thanks for the donation . glad to help. Quote Link to comment https://forums.phpfreaks.com/topic/130897-solved-mysql-date-functions-and-adding-will-pay-for-help/#findComment-679495 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.