If the registration has no project record, and they go into it in the project editor, add a project record, instead of displaying "Invalid Project to Edit"!

This commit is contained in:
james 2012-03-22 14:56:50 +00:00
parent d1e12fd3c8
commit 3e0b4227bc

View File

@ -166,6 +166,12 @@ function project_load()
$q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$registrations_id."' AND year='".$config['FAIRYEAR']."'"); $q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$registrations_id."' AND year='".$config['FAIRYEAR']."'");
//check if it exists, if we didnt find any record, lets insert one //check if it exists, if we didnt find any record, lets insert one
$projectinfo=mysql_fetch_object($q); $projectinfo=mysql_fetch_object($q);
if(!$projectinfo) {
mysql_query("INSERT INTO projects (registrations_id,projectcategories_id,year) VALUES ('".$registrations_id."','$projectcategories_id','".$config['FAIRYEAR']."')");
//and then pull it back out
$q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$registrations_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 //make sure that if they changed their grade on the student page, we update their projectcategories_id accordingly
if($projectcategories_id && $projectinfo->projectcategories_id!=$projectcategories_id) { if($projectcategories_id && $projectinfo->projectcategories_id!=$projectcategories_id) {