Jump to content

how-can-i-develop-fine-calculation-using-php-and-sql


309saurabhd

Recommended Posts

I want to develop a library system in which fine will be calculated as follows- the code should be in php and sql database. I want to retrieve date from database and subtract it from current date. The difference will be then multiplied with 5 to know the fine. How can I do this? How can i retrieve date from database and subtract it from current date?

returndate is column name from where i want to retrieve date for id=1 and issret is the table name.

<form id="form1" name="form1" method="post" action=""><label for="txtDueDate"></label><input type="text" name="DueDate" id="txtDueDate" /><input type="submit" name="submit" id="submit" value="Submit" /></form><?phpif(isset($_POST['submit'])){$result=mysql_query("select returndate from issret where id=1"); if(mysql_num_rows($result)>0){$x=date("Y/m/d");$diff=date_diff($result,$x);echo $diff->format("%R%a days");}}?>

Link to comment
Share on other sites

mysql_query does not return a value from a column, it returns a result set. You should look at the manual page for it. Even better, you should notice the giant red warning on the manual page for mysql_query about how you shouldn't use it any more, and switch your code to use PDO instead of the mysql extension.

Link to comment
Share on other sites

mysql_query does not return a value from a column, it returns a result set. You should look at the manual page for it. Even better, you should notice the giant red warning on the manual page for mysql_query about how you shouldn't use it any more, and switch your code to use PDO instead of the mysql extension.

can you please provide the link?

Link to comment
Share on other sites

  • 4 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...