From eb7b4e17549f5348be9842403c1145958c2bfe55 Mon Sep 17 00:00:00 2001 From: james Date: Mon, 2 Nov 2009 05:45:39 +0000 Subject: [PATCH] Send trophy info to the client on a getaward --- remote.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/remote.php b/remote.php index 8af20ea..92a9372 100644 --- a/remote.php +++ b/remote.php @@ -91,6 +91,7 @@ function handle_getawards(&$u, $fair, &$data, &$response) $award['name_en'] = $a['name']; $award['criteria_en'] = $a['criteria']; $award['upload_winners'] = $ul[$a['id']]; + if($a['sponsors_id']) { $sq = mysql_query("SELECT * FROM sponsors WHERE id='{$a['sponsors_id']}'"); if(mysql_num_rows($sq)) { @@ -102,14 +103,17 @@ function handle_getawards(&$u, $fair, &$data, &$response) $award['prizes'] = array(); $pq = mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='{$a['id']}'"); while($p = mysql_fetch_assoc($pq)) { - $prize = array(); - $prize['identifier'] = ""; - $prize['cash'] = $p['cash'];; - $prize['scholarship'] = $p['scholarship']; - $prize['value'] = $p['value']; - $prize['prize_en'] = $p['prize']; - $prize['number'] = $p['number']; - $prize['ord'] = $p['order']; + /* Map array keys -> local database field */ + $map = array( 'cash' => 'cash', 'scholarship' => 'scholarship', + 'value' => 'value', 'prize_en' => 'prize', 'number'=>'number', + 'ord'=>'order', + 'trophystudentkeeper'=>'trophystudentkeeper', + 'trophystudentreturn'=>'trophystudentreturn', + 'trophyschoolkeeper'=>'trophyschoolkeeper', + 'trophyschoolreturn'=>'trophyschoolreturn'); + $prize = array('identifier' => ''); + foreach($map as $k=>$field) $prize[$k] = $p[$field]; + $award['prizes'][] = $prize; } $awards[] = $award;