You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
1.5 KiB

<?php
include "header.php";
//print_r($_POST);exit;
if (isset($_POST['update'])) {
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
$arr = [];
$sel_option_arr = explode(",", $sel_option_all);
foreach ($sel_option_arr as $val) {
list($kind, $no, $score) = explode("-", $val);
$item_no = str_pad($no, 2, "0", STR_PAD_LEFT);
$arr[$kind][$item_no] = $score;
}
$record = json_encode($arr, JSON_UNESCAPED_UNICODE);
$db_query = "update schedule_check set actual_date = '".date("Y-m-d")."', record = '$record', score = '$db_total_score', memo = '$memo', updater = '$user_id' where id = '$id'";
mysqli_query($link, $db_query);
$affected = mysqli_affected_rows($link);
mysqli_close($link);
}
if ($affected > 0) {
// 如果有一筆以上代表有更新
// mysqli_insert_id可以抓到第一筆的id
//$new_id= mysqli_insert_id ($link);
echo "<script type = 'text/JavaScript'>";
echo "alert('update成功');";
echo "location.href='schedule_check-index.php?function_name=schedule_check&".$token_link."';";
echo "</script>";
} elseif ($affected == 0) {
echo "<script type = 'text/JavaScript'>";
echo "alert('無新增資料');";
echo "location.href='schedule_check-index.php?function_name=schedule_check&".$token_link."';";
echo "</script>";
}
else {
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
}
?>