science-ation/admin/judges.inc.php

107 lines
2.0 KiB
PHP
Raw Normal View History

<?
function getJudgingTeams()
{
global $config;
$q=mysql_query("SELECT judges_teams.id,
judges_teams.num,
judges_teams.name,
judges.id AS judges_id,
judges.firstname,
judges.lastname,
judges_teams_link.captain
FROM
judges,
judges_teams,
judges_teams_link
WHERE
judges_teams.year='".$config['FAIRYEAR']."' AND
judges_teams_link.judges_id=judges.id AND
judges_teams_link.judges_teams_id=judges_teams.id
ORDER BY
name,
num,
captain DESC,
lastname,
firstname");
$lastteamid=-1;
$lastteamnum=-1;
echo mysql_error();
$teams=array();
while($r=mysql_fetch_object($q))
{
if($r->id!=$lastteamid)
{
$teams[$r->id]['id']=$r->id;
$teams[$r->id]['num']=$r->num;
$teams[$r->id]['name']=$r->name;
$lastteamid=$r->id;
$lastteamnum=$r->num;
}
$teams[$lastteamid]['members'][]=array(
"id"=>$r->judges_id,
"firstname"=>$r->firstname,
"lastname"=>$r->lastname,
"captain"=>$r->captain
);
}
return $teams;
}
function getJudgingTeam($teamid)
{
global $config;
$q=mysql_query("SELECT judges_teams.id,
judges_teams.num,
judges_teams.name,
judges.id AS judges_id,
judges.firstname,
judges.lastname,
judges_teams_link.captain
FROM
judges,
judges_teams,
judges_teams_link
WHERE
judges_teams.year='".$config['FAIRYEAR']."' AND
judges_teams_link.judges_id=judges.id AND
judges_teams_link.judges_teams_id=judges_teams.id AND
judges_teams.id='$teamid'
ORDER BY
name,
num,
captain DESC,
lastname,
firstname");
$team=array();
$first=true;
while($r=mysql_fetch_object($q))
{
//this only gets done the first time
if($first)
{
$team['id']=$r->id;
$team['num']=$r->num;
$team['name']=$r->name;
$first=false;
}
$team['members'][]=array(
"id"=>$r->judges_id,
"firstname"=>$r->firstname,
"lastname"=>$r->lastname,
"captain"=>$r->captain
);
}
return $team;
}
?>