32 lines
878 B
PHP
32 lines
878 B
PHP
<?php
|
|
include 'koneksi.php';
|
|
$month = 2;
|
|
$year = 2026;
|
|
|
|
$stmt = $pdo->prepare("SELECT * FROM schedule WHERE MONTH(date)=? AND YEAR(date)=? ORDER BY date ASC");
|
|
$stmt->execute([$month, $year]);
|
|
$rows = $stmt->fetchAll();
|
|
|
|
echo "Total rows: " . count($rows) . "<br>";
|
|
|
|
$eventsByDate = [];
|
|
foreach($rows as $r){
|
|
$d = $r['date'];
|
|
if(!isset($eventsByDate[$d])) $eventsByDate[$d] = [];
|
|
$eventsByDate[$d][] = $r;
|
|
}
|
|
|
|
echo "Dates with events: " . count($eventsByDate) . "<br>";
|
|
foreach($eventsByDate as $k => $v){
|
|
echo "$k => " . count($v) . " events: ";
|
|
foreach($v as $ev) echo htmlspecialchars($ev['kegiatan']) . ", ";
|
|
echo "<br>";
|
|
}
|
|
|
|
// Test sprintf match
|
|
$d = 21;
|
|
$ds = sprintf('%04d-%02d-%02d', $year, $month, $d);
|
|
echo "<br>Testing date key: $ds<br>";
|
|
echo "isset? " . (isset($eventsByDate[$ds]) ? "YES (".count($eventsByDate[$ds]).")" : "NO") . "<br>";
|
|
?>
|