Files
HotLunches/special-schools.php
T
2026-10-19 15:22:52 -07:00

26 lines
826 B
PHP

<?php
header('Content-type: text/html; charset=utf8');
include "db.php";
$query = "SELECT * FROM schools WHERE status = 'Special' ORDER BY school_name";
$schools = db_query($query);
$cutoff = date("Y-m-d", time() - 60 * 60 * 24 * 50);
$pattern = "%-60s %10s %10s %10s\n";
printf($pattern, "School", "Parents", "Students", "Orders");
while ($row = db_fetch_assoc($schools)) {
extract($row);
$students = db_getVal("SELECT count(*) FROM people WHERE school_num = $record_num AND people_type = 'Student'");
$parents = db_getVal("SELECT count(*) FROM users WHERE school_num = $record_num AND type = 'Parent'");
$orders = db_getVal("SELECT count(*) FROM hotlunch_order_header WHERE school_num = $record_num AND added_date > '$cutoff'");
printf($pattern, $school_name, $parents, $students, $orders);
}
?>