RomeoX Posted January 27, 2010 Share Posted January 27, 2010 Hi there, Actually my problem is I want to get the date difference if date return of book more than one month add $10 if not leave the amountoffine to $0 and if the loaner took the book and return it after 3 months I want the code to add by monthly $10 so after 3 months I want the result to be $30. Here is the code <?php include 'functions.php'; $submit = $_POST["checkfine"]; $borrowid = $_POST["borrowid"]; $bookid = $_POST["bookid"]; $returned = $_POST["returned"]; $datereturned = $_POST['datereturned']; if ($datereturned > 30 Days)) { $query = mysql_query("UPDATE bookoutonloan SET amountoffine = (amountoffine + 10) WHERE DATE_ADD(datereturned , INTERVAL 1 MONTH )> CURDATE() AND borrowid = '$borrowid'"); die("The Record of Fine Has Been Updated"); } ?> So I want to add an amount of Fine like if someone loan a book and return it after 1 month I want to add $10 in the column of amountoffine actually I stuck here. This is my Table in mysql as well CREATE TABLE `library`.`bookoutonloan` ( `borrowid` INT( 12 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `stid` INT( 12 ) NOT NULL, `bookid` INT( 12 ) NOT NULL, `userid` INT( 12 ) NOT NULL, `libraryid` INT( 12 ) NOT NULL, `dateborrow` DATE NOT NULL , `datedueforreturn` DATE NOT NULL , `datereturned` DATE NOT NULL , `amountoffine` INT( 12 ) ) ENGINE = MYISAM ; I want to check is "databorrow" larger than one month, if it's more than one month set $10 if not leave the column $0. But the code is adding $10 every time that I refresh the page and also there is an error in this code when I used IF condition. so if I have "dateborrow" = 2010-01-12 it should not add $10 in case if today is 2010-01-26 if the "dateborrow" =2009-12-04 it should add $10 and so one even if the "dateborrow" =2009-08-10 it should be now $50 so every month it will increase $10 so it will be now $50 I hope you get what I want and clear. Thanks Quote Link to comment Share on other sites More sharing options...
RomeoX Posted January 27, 2010 Author Share Posted January 27, 2010 I really need your help guys. I need your brainstorm. I need a solution for my problem. I'm asking small editing coding. So please help me if you don't mind. Thanks 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.