$result = mysql_query("select lock_item from field_item where fi_id=" . $fiid, $con);
$flag = true;
while ($row = mysql_fetch_row($result)) {
    if ($row[0] == 1) {
        $flag = false;
        echo "Locked1";
    }
}
//ESDB::OpenConnUTF8();
if (flag) {
    foreach ($json as $key => $value) {
        list($f, $id) = split('_', $key);
        $sql = "update field_rc set {$f}=\"" . v_replace($value) . "\" where frc_id='{$id}' ";
        //and staf_ref='$regstafref';";
        if ($f == 'HJ') {
            $sql = "update field_item set {$id}=\"" . v_replace($value) . "\" where fi_id='{$fiid}' ";
            echo $sql;
        }
        mysql_query($sql, $con);
        if (mysql_affected_rows($con) == 1) {
            echo "({$key}) 1 µ§\n";
        }
        // print "$key => $value\n".$sql;
    }
}
mysql_close($con);
//ESDB::CloseConn();
?>


}
$db_selected = mysql_select_db(cfg::$db, $con);
mysql_query("SET NAMES UTF8");
$result = mysql_query("select lock_item from sport_item where si_id=" . $_REQUEST['siid'], $con);
$flag = true;
while ($row = mysql_fetch_row($result)) {
    if ($row[0] == 1) {
        $flag = false;
        echo "Locked1";
    }
}
//ESDB::OpenConnUTF8();
if (flag) {
    foreach ($json as $key => $value) {
        list($f, $id) = split('_', $key);
        $sql = "update sport_rc set {$f}=\"" . v_replace($value) . "\" where rc_id='{$id}' ";
        //and staf_ref='$regstafref';";
        mysql_query($sql, $con);
        if (mysql_affected_rows($con) == 1) {
            echo "({$key}) 1 µ§\n";
        }
        // print "$key => $value\n".$sql;
    }
}
mysql_close($con);
//ESDB::CloseConn();
?>