project information form

This commit is contained in:
james 2004-12-07 15:28:59 +00:00
parent 3a212ae5d5
commit 38d4fc5e81

View File

@ -28,11 +28,75 @@ echo mysql_error();
exit;
}
$r=mysql_fetch_object($q);
$authinfo=mysql_fetch_object($q);
//send the header
send_header("Participant Registration - Project Information");
echo "<a href=\"register_participants_main.php\">&lt;&lt; ".i18n("Back to Participant Registration Summary")."</a><br />";
echo "<br /><br />";
//now lets find out their MAX grade, so we can pre-set the Age Category
$q=mysql_query("SELECT MAX(grade) AS maxgrade FROM students WHERE registrations_id='".$_SESSION['registration_id']."'");
$gradeinfo=mysql_fetch_object($q);
//now lets grab all the age categories, so we can choose one based on the max grade
$q=mysql_query("SELECT * FROM projectcategories ORDER BY id");
while($r=mysql_fetch_object($q))
{
//save these in an array, just incase we need them later (FIXME: remove this array if we dont need it)
$agecategories[$r->id]['category']=$r->category;
$agecategories[$r->id]['mingrade']=$r->mingrade;
$agecategories[$r->id]['maxgrade']=$r->maxgrade;
if($gradeinfo->maxgrade >= $r->mingrade && $gradeinfo->maxgrade <= $r->maxgrade)
{
$projectcategories_id=$r->id;
}
}
//now select their project info
$q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
//check if it exists, if we didnt find any record, lets insert one
if(mysql_num_rows($q)==0)
{
mysql_query("INSERT INTO projects (registrations_id,projectcategories_id,year) VALUES ('".$_SESSION['registration_id']."','$projectcategories_id','".$config['FAIRYEAR']."')");
//now query the one we just inserted
$q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
}
$projectinfo=mysql_fetch_object($q);
//make sure that if they changed their grade on the student page, we update their projectcategories_id accordingly
if($projectinfo->projectcategories_id!=$projectcategories_id)
{
echo notice(i18n("Age category changed, updating to %1",array($agecategories[$projectcategories_id]['category'])));
mysql_query("UPDATE projects SET projectcategories_id='$projectcategories_id' WHERE id='$projectinfo->id'");
}
echo "<a href=\"register_participants_main.php\">&lt;&lt; ".i18n("Back to Participant Registration Summary")."</a><br />";
echo "<br />";
echo "<table>";
echo "<tr><td>".i18n("Project Title").": </td><td><input type=\"text\" name=\"title\" size=\"50\" value=\"$r->title\" /></td></tr>";
echo "<tr><td>".i18n("Age Category").": </td><td>";
echo i18n($agecategories[$projectcategories_id]['category']);
echo " (".i18n("Grades %1-%2",array($agecategories[$projectcategories_id]['mingrade'],$agecategories[$projectcategories_id]['maxgrade'])).")";
echo "</td></tr>";
echo "<tr><td>".i18n("Division").": </td><td>";
$q=mysql_query("SELECT * FROM projectdivisions ORDER BY division");
echo "<select name=\"projectdivision_id\">";
echo "<option value=\"\">".i18n("Select a division")."</option>\n";
while($r=mysql_fetch_object($q))
{
if($r->id == $projectinfo->projectdivisions_id) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$r->id\">".htmlspecialchars(i18n($r->division))."</option>\n";
}
echo "</select>";
echo "</td></tr>";
echo "<tr><td>".i18n("Summary").": </td><td><textarea cols=\"70\" rows=\"15\" name=\"summary\">$r->summary</textarea><br />";
echo i18n("100 words maximum");
echo "</td></tr>";
echo "</table>";
send_footer();