220061
Well-Known Coder
Hello I'm trying to loop through my php array in jqeury but when I do that it days it doesn't exist. this is weird to me because I'm able to use the array to create an variable in jqeury. I need a loop that starts at the first date, and adds 1 day until it reaches the end date.
the php code
jqeury
the php code
PHP:
$huis_ID = $_GET['ID'];
$arraysession=array();
$sql = "SELECT start_datum, eind_datum FROM reserveringen WHERE huis_ID = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $huis_ID);
$stmt->execute();
$result = $stmt->get_result();
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
$start_datum = date('d-m-Y', strtotime($row['start_datum']));
$eind_datum = date('d-m-Y', strtotime($row['eind_datum']));
array_push($arraysession, $start_datum, $eind_datum);
}
$array_to_json=json_encode((array)$arraysession);
?>
jqeury
JavaScript:
var dates = <?php echo $array_to_json ?>; // this part works
console.log(dates);
function disableDates(date) {
var string = $.datepicker.formatDate('dd-mm-yy', date);
// this doesn't work because it doesn't understand what $array_to_json is
for(var i = dates; i < <?php $array_to_json ?>. length ; i++){
console. log(i);
}
return [dates.indexOf(string) == -1];
}