$extcss=''; require ("appheader.php"); require ("header_inline.php"); /*---------------*/ $sql = "select * from " . $table_prefix. "course order by sorting "; $stmt = $db->prepare($sql); $stmt->execute(); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rs as $r) { $courses[$r['code']] = $r; } /*---------------*/ $cpcolor = array( "#6a6a6a","#f5b401","#78ba00","#2572eb","#ad103c","#643001","#af1d00","#c1004f","#7301ad","#4516b3","#006ac1","#008287","#189800","#00c13f","#fe971c","#ff2e12","#ff1d77","#a93ffe","#1faeff","#56c5ff","#00d8cc", "#6a6a6a","#f5b401","#78ba00","#2572eb","#ad103c","#643001","#af1d00","#c1004f","#7301ad","#4516b3","#006ac1","#008287","#189800","#00c13f","#fe971c","#ff2e12","#ff1d77","#a93ffe","#1faeff","#56c5ff","#00d8cc" ); $bibno = getpostval_int("bibno"); $bibno = str_pad($bibno, 4, "0", STR_PAD_LEFT); $sql = "select " . $table_prefix. "runners.*, " . $table_prefix. "runner_groups.name_en as group_name_en, " . $table_prefix. "runner_groups.`name_zh-hant` as `group_name_zh-hant` from " . $table_prefix. "runners left join " . $table_prefix. "runner_groups on " . $table_prefix. "runners.age_group = " . $table_prefix. "runner_groups.id where bibno = :bibno"; $stmt = $db->prepare($sql); $stmt->bindValue(':bibno', $bibno, PDO::PARAM_INT); $stmt->execute(); $runner = $stmt->fetch(PDO::FETCH_ASSOC); //d($runner); //d( $courses); $course = $courses[$runner['course']]; //d($course); $sql = "select " . $table_prefix. "markers.`name_zh-hant`, " . $table_prefix. "markers.name_en, " . $table_prefix. "course_markers.distance, " . $table_prefix. "course_markers.course_code, " . $table_prefix. "course_markers.code, " . $table_prefix. "course_markers.marker_id from " . $table_prefix. "course_markers left join " . $table_prefix. "markers on " . $table_prefix. "markers.id = " . $table_prefix. "course_markers.marker_id where " . $table_prefix. "course_markers.course_code = :code order by " . $table_prefix. "course_markers.count"; $stmt = $db->prepare($sql); $stmt->bindValue(':code', $runner['course'], PDO::PARAM_STR); $stmt->execute(); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rs as $r) { $cp[$r['code']] = $r; } /*--------------------------------------------*/ $sql = "select * from " . $table_prefix. "trackrecord_summary where bibno = '" . $bibno . "' order by cp_count"; $stmt = $db->prepare($sql); // $stmt->bindValue(':bibno', $bibno, PDO::PARAM_STR); $stmt->execute(); $temprs = $stmt->fetchAll(PDO::FETCH_ASSOC); //d($sql); foreach ($temprs as $r) { $trackrecord_summary[$r['cp_code']] = $r; } /*--------------------------------------------*/ /*--------------------------------------------*/ foreach($trackrecord_summary as $a) { if($lastrecordtime) { $thisduration = s_datediff("h", $lastrecordtime, $a['recorddatetime'] ); $trackrecord_summary[$a['cp_code']]['sectionduration'] = $thisduration; } //if($lastdistance) //{ $thisdistance = $cp[$a['cp_code']]['distance'] - $lastdistance; $trackrecord_summary[$a['cp_code']]['sectiondistance'] = $thisdistance; //} $avg = $thisdistance / $thisduration; $trackrecord_summary[$a['cp_code']]['avgspeed'] = $avg; if ($a['cp_code'] != "SP") { $lastrecordtime = $a['recorddatetime']; $lastdistance = $cp[$a['cp_code']]['distance']; } else { $lastrecordtime = $course['startdatetime']; $lastdistance = 0; } } /*--------------------------------------------*/ //$latestcp = end($cp); //d($latestcp); //d($trackrecord_summary); //d($trackrecord_summary[$latestcp['code']]); $latest_record = end($trackrecord_summary); //d($latest_record); /*--------------------------------------------*/ $sql = "select bibno from " . $table_prefix. "trackrecord_summary where course_code = '" . $runner['course'] . "' order by place_course asc limit 1"; $stmt = $db->prepare($sql); // $stmt->bindValue(':bibno', $bibno, PDO::PARAM_STR); $stmt->execute(); $winner_ts = $stmt->fetch(PDO::FETCH_ASSOC); //d($winner_ts); /*--------------------------------------------*/ $sql = "select * from " . $table_prefix. "runners where bibno = '" . $winner_ts['bibno'] . "' limit 1"; $stmt = $db->prepare($sql); // $stmt->bindValue(':bibno', $bibno, PDO::PARAM_STR); $stmt->execute(); $winner = $stmt->fetch(PDO::FETCH_ASSOC); /*--------------------------------------------*/ $sql = "select * from " . $table_prefix. "trackrecord_summary where bibno = '" . $winner['bibno'] ."' order by cp_count"; $stmt = $db->prepare($sql); // $stmt->bindValue(':bibno', $bibno, PDO::PARAM_STR); $stmt->execute(); $temprs = $stmt->fetchAll(PDO::FETCH_ASSOC); //d($sql); foreach ($temprs as $r) { $winner_trackrecord_summary[$r['cp_code']] = $r; } /*--------------------------------------------*/ foreach($winner_trackrecord_summary as $a) { if($lastrecordtime) { $thisduration = s_datediff("h", $lastrecordtime, $a['recorddatetime'] ); $winner_trackrecord_summary[$a['cp_code']]['sectionduration'] = $thisduration; } //if($lastdistance) //{ $thisdistance = $cp[$a['cp_code']]['distance'] - $lastdistance; $winner_trackrecord_summary[$a['cp_code']]['sectiondistance'] = $thisdistance; //} $avg = $thisdistance / $thisduration; $winner_trackrecord_summary[$a['cp_code']]['avgspeed'] = $avg; if ($a['cp_code'] != "SP") { $lastrecordtime = $a['recorddatetime']; $lastdistance = $cp[$a['cp_code']]['distance']; } else { $lastrecordtime = $course['startdatetime']; $lastdistance = 0; } } /*--------------------------------------------*/ // check eorro last time slower to next time? $arr=array_msort($trackrecord_summary, array('cp_count'=>SORT_DESC)); $lastrecordtime = null; foreach($arr as $a) { if (!$lastrecordtime) {$lastrecordtime = $a['recorddatetime'];} if ($a['recorddatetime'] && $lastrecordtime < $a['recorddatetime']) { $trackrecord_summary[$a['cp_code']]['error'] = 1; } $lastrecordtime = $a['recorddatetime']; //echo $lastrecordtime; } //d($trackrecord_summary); if (!$iframe) { ?>
| : | if ($lastplace_course) { if ($lastplace_course > $ts['place_course'] ) echo $icon_up; if ($lastplace_course < $ts['place_course'] ) echo $icon_down; if ($lastplace_course == $ts['place_course'] ) echo $icon_keep; } ?> | ||
| : | if ($lastplace_gender) { if ($lastplace_gender > $ts['place_gender'] ) echo $icon_up; if ($lastplace_gender < $ts['place_gender'] ) echo $icon_down; if ($lastplace_gender == $ts['place_gender'] ) echo $icon_keep; } ?> | ||
| : | if ($lastplace_group) { if ($lastplace_group > $ts['place_group'] ) echo $icon_up; if ($lastplace_group < $ts['place_group'] ) echo $icon_down; if ($lastplace_group == $ts['place_group'] ) echo $icon_keep; } ?> | ||
| : | if ($lastplace_gender_group) { if ($lastplace_gender_group > $ts['place_gender_group'] ) echo $icon_up; if ($lastplace_gender_group < $ts['place_gender_group'] ) echo $icon_down; if ($lastplace_gender_group == $ts['place_gender_group'] ) echo $icon_keep; } ?> |