Greysoul Posted January 1, 2011 Share Posted January 1, 2011 so im trying to setup a page for my bills that i pay monthly so me and my gf can access it remotely whenever we need to. we have a few loans that we are paying off in installment loans every month so i created a table like the picture below (which is actually in excel but it looks about the same). i know how to pull via select and sum everything that i need but what i'm actually going for is this: every month on those certain due dates i'd like for the monthly payment to be subtracted from the balance automatically..and it show the reflected balance. i'm not sure how to go about such a thing though as i've never worked with dates and times. my logic is that i have to setup a beginning time stamp for it to work off of..and then every 30 days from that time stamp..subtract the payment. then again, there's not always 30 days in a month and it'd get off track. any ideas? [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 1, 2011 Share Posted January 1, 2011 Are any of the due dates later than the 28th of each month? Do you have cron capablities on your server? Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 1, 2011 Share Posted January 1, 2011 Just a rough idea... either set up a cron job on your server to run this script once a day, at say 3AM or you could setup windows task scheduler to start-your-brower-point-it-at-this-script once a day /* add an integer field to your table - call it dueday */ /* in that field simply put the date due ie 1, 13, 27 etc */ /* you could also use a datetime field BUT it would require a little more 'complex' query */ /* get current day without leading zero*/ $current_day = date("j"); /* create query that updates all records where the record due date equals the current day */ $query = "UPDATE tablename set balance = balance-payment where dueday = '$current_day'"; /* execute the query */ $result = mysql_query($query); Quote Link to comment Share on other sites More sharing options...
Greysoul Posted January 1, 2011 Author Share Posted January 1, 2011 none after the 28th and i've never heard of cron until now guess i'll have to take a look at that then ;o my host is godaddy so i'm checking to see if thats something they support. Quote Link to comment Share on other sites More sharing options...
Greysoul Posted January 1, 2011 Author Share Posted January 1, 2011 looks like they do have cron Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 1, 2011 Share Posted January 1, 2011 FYI cron - http://www.thesitewizard.com/general/set-cron-job.shtml Quote Link to comment Share on other sites More sharing options...
Greysoul Posted January 1, 2011 Author Share Posted January 1, 2011 yeah seems as if i have a cron manager so it pretty much schedules it and everything for me..all i have to do is assign a script to run on whatever day and time i want. thanks a lot! Quote Link to comment 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.