diff --git a/admin/schools.php b/admin/schools.php index fe24dc5..c4851fc 100644 --- a/admin/schools.php +++ b/admin/schools.php @@ -146,13 +146,26 @@ else $notice = 'saved'; } - else if($_POST['action'] == "participation") + else if($_POST['action'] == "save_participation") { - // WRITE ME! - // this needs to list through a list of _POST elements that will have the indicies - // "[school id]_fairs" and "[school id]"_olympics, with true/false values for each. - // they should be written to the "schools" table. - + // update the schools' participation in fairs an olympics to reflect the settings submitted + $olympicSet = array(); + $fairSet = array(); + foreach($_POST as $idx => $value){ + if(preg_match('/_olympics$/', $idx)){ + $parts = explode('_', $idx); + $olympicSet[] = $parts[0]; + }else if(preg_match('/_fairs$/', $idx)){ + $parts = explode('_', $idx); + $fairSet[] = $parts[0]; + } + } + $fairString = '(' . implode(',', $fairSet) . ')'; + $olympicString = '(' . implode(',', $olympicSet) . ')'; + mysql_query("UPDATE schools SET include_fairs = TRUE WHERE id IN $fairString"); + mysql_query("UPDATE schools SET include_fairs = FALSE WHERE id NOT IN $fairString"); + mysql_query("UPDATE schools SET include_olympics = TRUE WHERE id IN $olympicString"); + mysql_query("UPDATE schools SET include_olympics = FALSE WHERE id NOT IN $olympicString"); } if($_GET['action']=="delete" && $_GET['delete']) @@ -334,7 +347,7 @@ echo "> " . i18n("olympics") . ""; echo ""; } - echo "
".i18n("School")." | ";
---|