"機房", "B" => "車廂", "C" => "井道層場", "D" => "運行", "E" => "其它"]; $maintainance_arr = ["A" => "全包", "B" => "半包", "C" => "清包", "D" => "2個月保養一次"]; $db_query = "select * from schedule_check c where id = $id"; $data = mysqli_query($link, $db_query); $db_query = "select * from schedule_check_item order by item_no"; $res = mysqli_query($link, $db_query); while ($row = mysqli_fetch_array($res)) { $key1 = $row["item_no"][0]; $key2 = str_replace("0", "", substr($row["item_no"], -2)); $item_arr[$key1][$key2]["title"] = $row["item_title"]; $item_arr[$key1][$key2]["option"] = $row["item_option"]; $item_arr[$key1][$key2]["score"] = $row["top_score"]; } mysqli_free_result($res); $db_query = "select accountid, name from account where accounttype = 'B' order by id"; $res = mysqli_query($link, $db_query); while ($row = mysqli_fetch_array($res)) { $account_arr[$row["accountid"]] = $row["name"]; } mysqli_free_result($res); foreach($data as $data) : $record_arr = json_decode($data["record"], true); $sql = "select c.company, f.maintainance, f.facility_kind, f.takecertificatedate, f.repairerid from facility f, contract c where f.facilityno = '".$data["facilityno"]."' and f.contractno = c.contractno"; $res = mysqli_query($link, $sql); $row = mysqli_fetch_array($res); mysqli_free_result($res); ?>