php - How to get data from database between date pickers -



php - How to get data from database between date pickers -

i have simple form , contain 2 date pickers. start , end. date picker show mm-yy-dddd format. database table contain yyyy-mm-dd format. want info table.. how info format using mysql , php ?

<?php if(isset($_post['submitted'])){ // grab info $startdate = $_post['start_date']; $enddate = $_post['end_date']; // echo $startdate; // echo "<br />"; // echo $enddate; $result = mysql_query('select sum(amount) total tbl_loan (created between "'.$startdate.'" , "'.$enddate.'") '); $row = mysql_fetch_assoc($result); $sum = $row['total']; } ?>

use strtotime

if(isset($_post['submitted'])){ // grab info $startdate = $_post['start_date']; $enddate = $_post['end_date']; // echo $startdate; // echo "<br />"; // echo $enddate; $result = mysql_query('select sum(amount) total tbl_loan (created between "'.date("y-m-d", strtotime($startdate)).'" , "'.date("y-m-d", strtotime($enddate)).'") '); $row = mysql_fetch_assoc($result); $sum = $row['total']; }

strtotime converts date string in format unix timestamp. there, date format covert specified format.

php mysql

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -