Jquery date picker selected date is not filtering data for fpdf report. (I have added the related codes below.)
$(document).ready(function() {
$("#datepicker12").datepicker({ dateFormat: 'yy-mm-dd' });
$("#datepicker12").datepicker("setDate", new Date);
});
<form id="salesReportForm" name="salesReportForm" method="post" action="../reports/dailyreports.php" >
<input id="datepicker12" name="datepicker12" tabindex="6" class="txtbx" />
<a target="popup" onclick="window.open('../reports/monthlyreports.php','popup','width=1200,height=900'); return false;">
<input type="button" name="btnMonthlyReports" id="btnMonthlyReports" value="GENERATE" />
</a>
if(isset($_POST['datepicker12'])){ $date = $_POST['datepicker12'];}
$result=mysqli_query($connection,"SELECT S.sales_id, I.item_name, ST.stock_code, S.qty, S.unit_price, S.discount, S.amount, S.date
FROM sales S
INNER JOIN items I ON S.item_id=I.item_id
INNER JOIN stock ST ON S.stock_id=ST.stock_id WHERE S.date BETWEEN $date.'00:00:00' AND $date.'23:59:59'");
$pdf->Cell(25,6,$date,'B',0,'L',0);
When I debug the code, below error appears.
"Errormessage: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''00:00:00' AND .'23:59:59'' at line 4 "
Appreciate your help to resolve this.
I have figured out the issue, and now it works perfectly. I removed <a>
from wrapping the submit button, and it worked.
Edited code is as below:
<form id="dailysalesReportForm" name="dailysalesReportForm" method="post" action="../reports/dailyreports.php" ><tr>
<td width="147" height="34"><div align="left">DAILY</div></td>
<td width="116"><label>
<div align="center">
<input id="datepicker12" name="datepicker12" tabindex="6" class="txtbx" />
</div>
</label>
<div align="center"></div></td>
<td width="104"><div align="center"></div></td>
<td width="81"><label>
<div align="center">
<input type="submit" name="btnDailyReports" id="btnDailyReports" value="GENERATE"/>
</div>
</label></td>
</tr></form>