$q=mysql_query("SELECT * FROM students WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
if(mysql_num_rows($q)==0)
{
//uhh oh, we didnt find any, this isnt possible! lets insert one using the logged in persons email address
//although... this can never really happen, since the above queries only allow the page to view if the student
//is found in the students table... soo... well, lets leave it here as a fallback anyways, just incase
mysql_query("INSERT INTO students (registrations_id,email,year) VALUES ('".$_SESSION['registration_id']."','".mysql_escape_string($_SESSION['email'])."','".$config['FAIRYEAR']."')");
}
elseif(mysql_num_rows($q)==1)
{
$numstudents1="checked=\"checked\"";
$numstudents2="";
}
elseif(mysql_num_rows($q)==2)
{
$numstudents1="";
$numstudents2="checked=\"checked\"";
}
else
{
//this should never happen
//we cant have more than two on a project
echoerror(i18n("More than two students associated with this registration"));
//FIXME: eventually provide a solution to fix this if it ever happens.. like say....
// "click here" to remove all students and start again.. or something