Jump to content

how to set value depends on date


RomeoX

Recommended Posts

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

 

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.