query("SELECT COUNT(*) FROM featured_activities WHERE status = 'approved' OR status IS NULL")->fetchColumn(); // SELECT + LIMIT/OFFSET $stmt = $pdo->prepare(" SELECT id, title, description, poster_url, activity_type, activity_type_other, activity_date, start_date, end_date, start_time, end_time, location, province, district, sub_district, target_group, target_count, participant_count, link_url FROM featured_activities WHERE status = 'approved' OR status IS NULL ORDER BY COALESCE(start_date, activity_date) DESC, id DESC LIMIT ? OFFSET ? "); $stmt->bindValue(1, $per_page, PDO::PARAM_INT); $stmt->bindValue(2, $offset, PDO::PARAM_INT); $stmt->execute(); $activities_query = $stmt->fetchAll(); } catch (Exception $e) { $total = 0; $activities_query = []; } $pg = paginateSql($total, $page, $per_page); $pg['items'] = $activities_query; // ฟังก์ชันแสดง URL รูปภาพ function activity_image_url($poster) { if (empty($poster)) { return 'https://images.unsplash.com/photo-1540575467063-178a50c2df87?ixlib=rb-4.0.3&auto=format&fit=crop&w=800&q=80'; } if (strpos($poster, 'http') === 0) return $poster; return 'admin/upload/' . $poster; } // ฟังก์ชันแสดงช่วงวันที่ function format_activity_date($act) { $start = $act['start_date'] ?? $act['activity_date'] ?? ''; $end = $act['end_date'] ?? ''; if (empty($start)) return '-'; if (empty($end) || $end === $start) return $start; return $start . ' ถึง ' . $end; } // ฟังก์ชันแสดงช่วงเวลา function format_activity_time($act) { $s = $act['start_time'] ?? ''; $e = $act['end_time'] ?? ''; if (empty($s) && empty($e)) return ''; if (!empty($s) && !empty($e)) return substr($s,0,5) . ' - ' . substr($e,0,5) . ' น.'; return substr($s ?: $e, 0, 5) . ' น.'; } ?>

กิจกรรมเด่นประจำเดือน

สำรวจตารางกิจกรรมและเรื่องราวเด่นจากแหล่งเรียนรู้ภูมิปัญญาท้องถิ่นทั่วประเทศ

$act): // เตรียมข้อมูลสำหรับ modal — เก็บใน data attribute เพื่อไม่ต้องเรียก server เพิ่ม $modal_data = [ 'title' => $act['title'] ?? '', 'poster' => activity_image_url($act['poster_url'] ?? ''), 'type' => ($act['activity_type'] === 'อื่นๆ' && !empty($act['activity_type_other'])) ? 'อื่นๆ (' . $act['activity_type_other'] . ')' : ($act['activity_type'] ?? ''), 'date' => format_activity_date($act), 'time' => format_activity_time($act), 'location' => $act['location'] ?? '', 'province' => $act['province'] ?? '', 'district' => $act['district'] ?? '', 'sub_district' => $act['sub_district'] ?? '', 'target_group' => $act['target_group'] ?? '', 'target_count' => $act['target_count'] ?? '', 'participant_count' => $act['participant_count'] ?? '', 'description' => $act['description'] ?? '', 'link_url' => $act['link_url'] ?? '', ]; ?>
<?php echo htmlspecialchars($act['title']); ?>

·
คน

ขณะนี้ยังไม่มีข้อมูลกิจกรรมที่น่าสนใจในระบบ

0): ?>