46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<pre>
|
|
<?php
|
|
include "db.php";
|
|
|
|
$mode = "detail";
|
|
$mode = "summary";
|
|
|
|
|
|
$earliest_date = db_getVal("SELECT min(start_date) FROM schools WHERE status = 'Active'");
|
|
$latest_date = db_getVal("SELECT max(start_date) FROM schools WHERE status = 'Active'");
|
|
|
|
$first_month = substr($earliest_date,0,7);
|
|
$last_month = substr($latest_date,0,7);
|
|
|
|
$currMonth = $first_month;
|
|
$Year = substr($currMonth,0,4);
|
|
$Month = substr($currMonth,5,2);
|
|
|
|
$total = 0;
|
|
|
|
while ($currMonth <= $last_month) {
|
|
$numSchools = db_getVal("SELECT count(*) FROM schools WHERE status = 'Active' AND start_date LIKE '$currMonth%'");
|
|
$total += $numSchools;
|
|
printf("%s,%d,%d\n",$currMonth,$numSchools,$total);
|
|
|
|
if ($mode == "detail") {
|
|
$results = db_query("SELECT school_name, city, province, country, referred_by FROM schools WHERE status = 'Active' AND start_date LIKE '$currMonth%'");
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
// printf(" - %-80s %s\n",$school_name. " - $city, $province",$referred_by);
|
|
// printf(" - %s\n",$school_name. " - $city, $province");
|
|
printf("%s\n",$school_name. " - $city, $province");
|
|
}
|
|
}
|
|
|
|
$Month++;
|
|
if ($Month > 12) {
|
|
$Month = 1;
|
|
$Year++;
|
|
}
|
|
$currMonth = sprintf("%d-%02d",$Year,$Month);
|
|
}
|
|
|
|
echo("Total,$total\n");
|
|
?>
|