'ok', 'err' => ''); try { if (empty($_POST) || empty($_POST["id"])) throw new \Exception("id empty"); if (empty($_COOKIE["_m"])) throw new \Exception("user empty"); foreach ($_POST as $k => $v) { $$k = htmlspecialchars(stripslashes(trim($v))); } require_once "database.php"; list($uid, $uname) = explode(";", unserialize($_COOKIE["_m"])); $db_query = "select a.id, a.contractno, a.case_name, a.address, a.price_total from pricereview_main a where a.id not in ("; $db_query .= "select b.pr_main_id from contractapply_main b where b.pr_main_id = a.id) "; $db_query .= "and a.id = '$id' and a.creater = '$uid' and a.last_check_result = 'Y'"; $res = mysqli_query($link, $db_query); if (mysqli_num_rows($res) == 0) { mysqli_free_result($res); throw new \Exception("no data"); } foreach ($res as $v) { $rarr["contractno"] = $v["contractno"]; $rarr["case_name"] = $v["case_name"]; $rarr["address"] = $v["address"]; $rarr["price_total"] = $v["price_total"]; } mysqli_free_result($res); $db_query = "select id, item_no, item_group, item_spec, item_qty, item_price_bp from pricereview_item where mid = '$id' order by id"; $res = mysqli_query($link, $db_query); foreach ($res as $v) { //print_r($v); $rarr["item"][] = $v; } mysqli_free_result($res); }catch(\Exception $e) { $rarr['st'] = 'err'; $rarr['err'] = $e->getMessage(); } echo json_encode($rarr, JSON_UNESCAPED_UNICODE); ?>