Lukeidiot Posted February 21, 2011 Share Posted February 21, 2011 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: 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. Quote Link to comment https://forums.phpfreaks.com/topic/228446-calculating-monthly-subscriptions/ Share on other sites More sharing options...
PaulRyan Posted February 22, 2011 Share Posted February 22, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/228446-calculating-monthly-subscriptions/#findComment-1178246 Share on other sites More sharing options...
PFMaBiSmAd Posted February 22, 2011 Share Posted February 22, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/228446-calculating-monthly-subscriptions/#findComment-1178249 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.