309saurabhd Posted February 24, 2015 Share Posted February 24, 2015 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 More sharing options...
justsomeguy Posted February 24, 2015 Share Posted February 24, 2015 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 More sharing options...
309saurabhd Posted February 25, 2015 Author Share Posted February 25, 2015 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 More sharing options...
davej Posted February 25, 2015 Share Posted February 25, 2015 Perhaps... http://php.net/manual/en/pdo.query.php Link to comment Share on other sites More sharing options...
rushikesh Posted January 14, 2020 Share Posted January 14, 2020 309saurabhd hello i have same problem in my program can you help me about it Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now