Jump to content
309saurabhd

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

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");}}?>

Share this post


Link to post
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.

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...

×
×
  • Create New...