foreach ($subject_ids as $subj_id) { $response_ids = array(); $query = "SELECT response_id FROM results WHERE `study_id` = '".$study_id."' AND `subj_id` = '".$subj_id."'"; $result = mysql_query($query); confirm_query($result); while ($row = mysql_fetch_assoc($result)) { $response_ids[] = $row['response_id']; } $response_ids = array_unique($response_ids); foreach($response_ids as $response_id){ $query = "SELECT * FROM results WHERE `study_id`='".$study_id."' AND `subj_id`='".$subj_id."' AND `response_id`='".$response_id."'"; $result = mysql_query($query); confirm_query($result); while ($row = mysql_fetch_assoc($result)) { $data['subj_id'] = $subj_id; $data['subj_name'] = get_subj_name($subj_id); if($study_type == '360') { $data['rel_subj_name'] = get_subj_name(get_rel_subj_id($subj_id, $response_id)); $data['relation'] = $relatii[get_relation($subj_id, $response_id)]; } $data[$row['question_id']] = $row['data']; } fputcsv($outstream, $data); } } fclose($outstream); } ?>
function excel_upload($file) { global $db; ini_set('memory_limit', '128M'); require QISHI_ROOT_PATH . 'genv/spreadsheet-reader/php-excel-reader/excel_reader2.php'; require QISHI_ROOT_PATH . 'genv/spreadsheet-reader/SpreadsheetReader.php'; $reader = new SpreadsheetReader($file); // error_reporting(E_ALL ^ E_NOTICE); $data = array(); $cols = array(); //存储字段信息; foreach ($reader as $item) { $data[] = $item; } if (!is_array($data) || count($data) < 2) { return false; } foreach (array_shift($data) as $key => $value) { $colinfo = get_relation(trim($value), 1); if ($colinfo && $colinfo["value"]) { switch (trim($colinfo["value"])) { case "birthdate": $func = "birthdate"; break; default: $func = "trim"; break; } $colinfo["func"] = $func; $cols[$key] = $colinfo; } } $obj = array(); foreach ($data as $key => $value) { foreach ($cols as $m => $n) { if ($n["value"]) { $temp_array = explode(',', $value[$m]); $cc = array(); foreach ($temp_array as $p => $q) { $cc[] = get_relation($q); } $filter_value = join(",", $cc); $obj[$key][$n["value"]] = call_user_func_array(array("Ggven", $n["func"]), array($filter_value)); } } } foreach ($obj as $key => $item) { if ($item["fullname"] == "") { unset($obj[$key]); } } return array("cols" => $cols, "data" => $obj); }
function test_get_relation() { CCTM::$post_id = 77; $rel = get_relation('poster_image'); $this->assertTrue($rel['ID'] == 120); }
</thead> <tbody id="related_body" > <?php if (!empty($related_childs)) { foreach ($related_childs as $child) { ?> <tr class="permanent count_row"> <td><a class="make_green" href="<?php echo site_url('child/view/' . $child->child_id); ?> "><?php echo $child->name; ?> </a></td> <td><?php echo get_relation($child->relation_id); ?> </td> <td><?php echo $child->contact_priority == 1 ? 'Primary' : 'Secondary'; ?> </td> <td><input disabled type="checkbox" name="can_pick[]" value="<?php echo $child->id; ?> " kin_id ="<?php echo $child->kin_id; ?> " <?php echo $child->can_pickup == 1 ? 'checked' : ''; ?>