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) { ?>
'; echo displayFirstLastname($runner['firstname'],$runner['lastname']) . ' (' . $runner['gender'] . ') ' . $runner['team']; } else { echo ''; echo "Error! BIB No. not exists"; } ?>

'; echo i18n_text("Overall Rank"); echo ''; echo '
'; echo ''; echo $trackrecord_summary['FP']['place_course']; echo ''; } if ($latest_record['dnf']) { echo ''; echo 'DNF'; echo ''; } else if (!$latest_record || !$latest_record['overall_place_group']) { echo ''; echo 'DNS'; echo ''; } else if (!$trackrecord_summary['FP'] and ( strtotime($course_cutofftime) < strtotime("now"))) { $latest_record['dnf'] = "DNF"; echo ''; echo 'DNF'; echo ''; } else { //echo "比賽中"; //echo i18n_text(""); } ?>
'; echo i18n_field($runner, "group_name") . " / " . i18n_text( $runner['gender'] . "_group"); echo ''; echo '
'; echo ''; echo $trackrecord_summary['FP']['place_gender_group']; echo ''; } ?>
prepare($sql); $stmt->execute(); $images = $stmt->fetchAll(PDO::FETCH_ASSOC); if ($images) { ?>
  • km '; echo i18n_text("Error occurred. It will be fixed as soon as possible. Sorry for the inconvenience"); echo ''; } ?>

    ' . $p['code'] . ' - '. MyDateDifference($courses[ $runner['course'] ]['startdatetime'], $ts['recorddatetime']) . "
    "; $latestcp_popup .= i18n_text("Record Time") . ":" . $ts['recorddatetime'] . '
    '; $latestcp_popup .= i18n_text("Place") . '
    '; $latestcp_popup .= $course['code'] . ': ' . $ts['place_course'] . '
    ' . $course['code'] . " / " . i18n_text( $ts['gender'] . "_group") . ': ' . $ts['place_gender'] . '
    ' . $course['code'] . " / " . i18n_field($runner, "group_name") . ': ' . $ts['place_group']. '
    ' . $course['code'] . " / " . i18n_field($runner, "group_name") . " / " . i18n_text( $ts['gender'] . "_group") . ': ' . $ts['place_gender_group']; if ($p['code'] == "SP") { echo '
    ' . i18n_text("Check In") . ': ' . $ts['recorddatetime'] . '
    '; } else { ?>
    :
    ' . i18n_text($ts['dnf']) . '
    '; } ?>
    '; $icon_down = ''; $icon_keep = ''; ?>
    : $ts['place_course'] ) echo $icon_up; if ($lastplace_course < $ts['place_course'] ) echo $icon_down; if ($lastplace_course == $ts['place_course'] ) echo $icon_keep; } ?>
    : $ts['place_gender'] ) echo $icon_up; if ($lastplace_gender < $ts['place_gender'] ) echo $icon_down; if ($lastplace_gender == $ts['place_gender'] ) echo $icon_keep; } ?>
    : $ts['place_group'] ) echo $icon_up; if ($lastplace_group < $ts['place_group'] ) echo $icon_down; if ($lastplace_group == $ts['place_group'] ) echo $icon_keep; } ?>
    : $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; } ?>
    "; //echo $ts['sectiondistance']; //echo "
    "; echo ''; echo i18n_text("Average Speed"); echo ''; echo "
    "; //printf('%0.2f', $avg); $padded = sprintf('%0.2f', $ts['avgspeed']); echo $padded . " " . i18n_text("Km") . "/" . i18n_text("Hr"); echo '
    '; ?>