<?php

define('GLOBAL_PATH', '../../../../');
define('ROOT_PATH', '../../../');
define('CURRENT_CATEGORY', 'athletica_tech');
define('CURRENT_PAGE', 'results');
require_once ROOT_PATH . 'lib/inc.init.php';
require_once ROOT_PATH . 'lib/cls.result_high.php';
$res = $_POST['res'];
$res_out = formatResultInput($res);
echo $res_out;
echo $athlete['ath_firstname'];
?>
</b></td>
        <td><?php 
echo $attempt . ". " . $lg['ATTEMPT'];
?>
</td>
    </tr>
    <tr>
        <td height="20px"></td>
    </tr>
</table>
<table>
    <tr>
        <td class="result"><input type="text" name="result_edit_result" id="result_edit_result" class="result" autocomplete="off" tabindex="101" value="<?php 
echo formatResultInput($result['result']);
?>
">
        <td class="wind">
            <?php 
if ($wind == 1) {
    ?>
                <input type="text" name="result_edit_wind" id="result_edit_wind" class="wind" autocomplete="off" tabindex="102" value="<?php 
    echo formatWindInput($result['wind']);
    ?>
">
                <?php 
}
?>
        </td>
        <td><button type="button" name="btn_editResult" id="btn_editResult" tabindex="103"><?php 
define('GLOBAL_PATH', '../../../../');
define('ROOT_PATH', '../../../');
define('CURRENT_CATEGORY', 'athletica_tech');
define('CURRENT_PAGE', 'results');
require_once ROOT_PATH . 'lib/inc.init.php';
require_once ROOT_PATH . 'lib/cls.result_high.php';
$return = "error";
$ath_res = $_POST['ath_res'];
$ath_id = $_POST['ath_id'];
$res_id = $_POST['res_id'];
$round = $_POST['round'];
$event = $_POST['event'];
$height = $_POST['height'];
try {
    $ath_res_db = formatResultInput($ath_res);
    if ($ath_res_db == 'error') {
        $return = 'result';
    } else {
        if ($ath_res_db) {
            $sql_sex = "SELECT Geschlecht \r\n                          FROM kategorie \r\n                     LEFT JOIN wettkampf USING(xKategorie) \r\n                     LEFT JOIN start USING(xWettkampf) \r\n                     LEFT JOIN serienstart USING(xStart) \r\n                         WHERE xSerienstart = :ath_id;";
            $query_sex = $glb_connection_server->prepare($sql_sex);
            $query_sex->bindValue(':ath_id', $ath_id);
            $query_sex->execute();
            $sex = $query_sex->fetch(PDO::FETCH_ASSOC);
            $sex = $sex['Geschlecht'];
            $points = calcPoints($event, $ath_res_db, $fraction = 0, $sex, $ath_id);
            $res_id_sql = !is_null($res_id) ? "xResultat = :res_id, " : "";
            $sql = "INSERT INTO resultat\r\n                            SET " . $res_id_sql . "\r\n                                Leistung = :height\r\n                                , Info = :ath_res\r\n                                , Punkte = :ath_pts\r\n                                , xSerienstart = :ath_id\r\n                    ON DUPLICATE KEY UPDATE\r\n                                Leistung = :height\r\n                                , Info = :ath_res\r\n                                , Punkte = :ath_pts\r\n                                , xSerienstart = :ath_id\r\n                                ;";
            $query = $glb_connection_server->prepare($sql);
            // +++ bind parameters