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

47 lines
1.4 KiB
PHP

<?php
include "db.php";
$school_num = 19058;
$students = array();
db_query("USE hotlunch_20161013");
$query = "SELECT p.*,u.first_name AS parent_first_name,u.last_name AS parent_last_name " .
"FROM people AS p, users AS u " .
"WHERE p.school_num = $school_num " .
"AND u.school_num = $school_num " .
"AND people_type = 'Student' " .
"AND p.user_num = u.record_num " .
"ORDER BY last_name, first_name";
$results = db_query($query);
while ($row = db_fetch_assoc($results)) {
$students[] = $row;
}
db_query("USE hotlunch");
for ($i = 0; $i < count($students); $i++) {
$row = $students[$i];
extract($row);
$query = "SELECT p.*,u.first_name AS parent_first_name,u.last_name AS parent_last_name " .
"FROM people AS p, users AS u " .
"WHERE p.school_num = $school_num " .
"AND u.school_num = $school_num " .
"AND people_type = 'Student' " .
"AND p.user_num = u.record_num " .
"AND p.record_num = $record_num";
$results = db_query($query);
$row = db_fetch_assoc($results);
if ($row['user_num'] != $user_num) {
echo("$record_num: $first_name $last_name - $parent_first_name $parent_last_name ($user_num)\n");
extract($row);
echo("$record_num: $first_name $last_name - $parent_first_name $parent_last_name ($user_num)\n");
echo("\n");
}
}
?>