Here is my PHP code which includes the MySQL database. In the MySQL database, there is one column 'amount' and another column is 'date'. I want to sum of the column amount between two dates. But I can't get my result. Please help me out.
<?Php
error_reporting(0);
include "config_1.php";
echo "<form method=post action='getcollectionbagnan.php' ><input type=hidden name=todo value=search>
<input type=date name=search_text value='$search_text' ><br>
<input type=hidden name=todo2 value=search2>
<input type=date name=search_text2 value='$search_text2' ><input type=submit value=Search><br>
</form>
";
$todo=$_POST['todo'];
$search_text=$_POST['search_text'];
$todo2=$_POST['todo2'];
$search_text2=$_POST['search_text2'];
if(isset($todo) and $todo=="search" and isset($todo2) and $todo2=="search2"){
$type=$_POST['type'];
$search_text=ltrim($search_text);
$search_text=rtrim($search_text);
$search_text2=ltrim($search_text2);
$search_text2=rtrim($search_text2);
if($type<>"any"){
$query="select sum(amount) from billbagnan where date between $search_text and $search_text2 ";
$count=$dbo->prepare($query);
$count->execute();
$sumAmount = 0;
while($row = $count->fetch()) {
$sumAmount = $row[0];
}
echo $sumAmount;
}
}
?>