Jump to content

Calculating Monthly Subscriptions


Lukeidiot

Recommended Posts

Okay guys, I figured out how to calculate monthly subscriptions into days, but I am stuck on calculating multiple monthly subscriptions.. for example

 

Heres my mysql table:

subsl.png

 

How would I calculate this:

Subscription Start: February 21, 2011, 12:00 am

Subscription End: April 22, 2011, 12:00 am

Subscription Left: 60 days

 

My trouble is that when the user buys another month, it calculates the end time based on the new "Subscription Start Date". Or vice versa.

 

Any ideas guys?

Thanks.

Link to comment
Share on other sites

Hello Lukeidiot.

 

Instead of inserting, or updating the purchase date. Why don't you just update the length of time the user is subscribed?

 

Some like the following would possibly do it:

1 - User decides buys Subscription

2 - Makes payment, call back to your PHP script

3 - PHP script checks to see if they already exist in the DB, if they do and the length of the new subscription to the length of the current one

4 - If they don't exist just add a new row?

 

I don't know if that is how you would like to do it?

 

Regards, PaulRyan.

Link to comment
Share on other sites

This thread is a double/cross post. Don't waste your time replying. Here's the active thread - http://www.phpfreaks.com/forums/php-coding-help/calculating-monthly-subscriptions-325102/

 

Edit: And you should treat this like a deposit account and record each addition to the account and get the total by calculating the current value. By simply maintaining the total, you loose a record of when amounts were added and it is also easy for logic errors to change the total and you have no idea what the value should be. 

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.