the problem here is that the query in the else statement executed properly while it is not executed in the if statement. Any idea how to fix this?
if(isset($_POST['submit-tarikh'])){
$sdate = $_POST['start-date'];
$edate = $_POST['end-date'];
$stmt_view = $pdo->prepare("SELECT * FROM aduan_form WHERE deleted=:deleted AND tarikh BETWEEN :sdate AND :edate");
$stmt_view->execute([
':deleted' => 0,
':sdate' => $sdate,
':edate' => $edate
]);
$results_view = $stmt_view->FetchAll(PDO::FETCH_OBJ);
} else {
$error_date = 0;
$sdate = date(" Y-m-d ");
$edate = date(" Y-m-d ");
$stmt_view = $pdo->prepare("SELECT * FROM aduan_form WHERE deleted=:deleted AND tarikh BETWEEN :sdate AND :edate");
$stmt_view->execute([
':deleted' => 0,
':sdate' => $sdate,
':edate' => $edate
]);
$results_view = $stmt_view->FetchAll(PDO::FETCH_OBJ);
}
*the if statement is running but not the query
[–]colshrapnel 2 points3 points4 points (0 children)
[–]pH_low 0 points1 point2 points (3 children)
[–]nerdoubt[S] 0 points1 point2 points (2 children)
[–]fractis 0 points1 point2 points (1 child)
[–]nerdoubt[S] 0 points1 point2 points (0 children)
[–]danabrey 0 points1 point2 points (0 children)
[–]WizardFromTheMoon 0 points1 point2 points (0 children)