Jump to content

[SOLVED] MySQL date functions and adding. Will PAY for help!


champbronc2

Recommended Posts

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.

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.