set_charset('utf8')) { // เปลี่ยน charset เป็น utf8 พร้อมตรวจสอบการเปลี่ยน printf('Error loading character set utf8: %sn', $mysqli->error); // ถ้าเปลี่ยนไม่ได้ exit; } //สิ้นสุดเชื่อมต่อฐานข้อมูล //เรียกค่าจากตารางการตั้งค่า $sql = 'select * from ' . tbl_prefix . 'tbl_system_config'; $result_cfg = $link->query($sql); //นำค่าที่ได้จากตารางตั้งค่ามาใส่ตัวแปลแบบคงที่ while ($cfg = $result_cfg->fetch_assoc()) { define($cfg['config_name'], $cfg['config_value']); } $op = test_input($_REQUEST['op']); function count_row($tbl, $condition) { global $link; $sql = "select count(*) as num from $tbl where $condition"; $result = $link->query($sql); $row = $result->fetch_assoc(); return $row['num']; } //กำหนดค่าให้กับ policy $sql="select * from tbl_system_policy"; $result_policy = $link->query($sql); while ($cfg = $result_policy->fetch_assoc()) { define($cfg['pol_url'], $cfg['pol_name'] . " " . $cfg['pol_detail']); } //กำหนดค่าให้กับ indicators $sql="select * from tbl_system_table"; $result_indicators = $link->query($sql); while ($cfg = $result_indicators->fetch_assoc()) { define($cfg['ind_url'] . "point", $cfg['point_name']); define($cfg['ind_url'], $cfg['ind_name'] . " " . $cfg['ind_detail']); define($cfg['ind_url'] . "exp", nl2br($cfg['ind_explanation'])); define($cfg['ind_url'] . "rnd1", $cfg['edu_type_round1']); define($cfg['ind_url'] . "rnd2", $cfg['edu_type_round2']); } function CalPercent($total, $num, $decimal_length) { if ($total == 0) { return 0; } else { $percent = ($num * 100) / $total; return number_format($percent, $decimal_length); } }