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
https://forums.phpfreaks.com/topic/228446-calculating-monthly-subscriptions/
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.

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. 

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.