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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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