I have a table where I need to show a list of meetings, it's based on dates (default showing next 7 days)and then via a form pick from > to dates. I've gotten that part to work, but the moment that it spans over multiple months, it returns no results. The current week for example, end of january / first few days of february.
In the MySQL DB they're formatted DD/MM/YYYY.
$til = $_POST['til'];
$fra = $_POST['fra'];
$myDate = date('d/m/Y');
$dateWeek = date('d/m/Y', strtotime(' + 7 days'));
if(isset($_POST['hent'])){
if (!$conn) {
die("Ingen forbindelse: " . mysqli_connect_error());
} else {
$sql = ("select * from kaffe WHERE dato >= '$fra' AND dato <= '$til' order by STR_TO_DATE(dato,'%d/%m/%Y'), meetingstart");
$sqlQuery = $conn->query($sql) or die($conn->error);
$sqlQuery->num_rows;
while($sqlFetch = $sqlQuery->fetch_object()){
echo "
Show 7 days results
";
}
}
}else{
$sql = ("select * from kaffe WHERE dato >= '$myDate' AND dato <= '$dateWeek' order by STR_TO_DATE(dato,'%d/%m/%Y'), meetingstart");
$sqlQuery = $conn->query($sql) or die($conn->error);
$sqlQuery->num_rows;
while($sqlFetch = $sqlQuery->fetch_object()){
echo "
Show from > to dates selected in the datepicker form
";
}
}
I'm guessing the formatting might be part of what's causing the issue, as most suggest the "expected" EU way is done with - instead of /. Had no success getting it to work though.