'ok', 'err' => ''); try { if (empty($_POST) || empty($_POST["fval"])) throw new \Exception("parameter empty"); foreach ($_POST as $k => $v) { $$k = htmlspecialchars(stripslashes(trim($v))); } list($source, $kind, $seat, $numberofstop, $speed, $op) = explode(",", $fval); if (!$source || !$kind || !$seat) throw new \Exception("parameter empty[2]"); if ($source == "F") { $db_query = "select id, price, price_mi, model from facility_price where kind = '$kind' and seat = '$seat' and numberofstop = '$numberofstop' "; $db_query .= "and speed = '$speed' and status = 'Y' order by id desc"; $res = mysqli_query($link, $db_query); if ($row = mysqli_fetch_row($res)) { $id = $row[0]; $price = $row[1]; $price_mi = $row[2]; $a=[$kind, $seat, $numberofstop, $op, $speed]; $ret = facility_spec([$kind, $seat, $numberofstop, $op, $speed]); list($model, $weight) = explode(",", $ret); } mysqli_free_result($res); if (!empty($id)) { $rarr["id"] = $id; $rarr["amt"] = $price; $rarr["iamt"] = "1".$price_mi; $rarr["model"] = $model; $rarr["group"] = "A"; $rarr["weight"] = $weight; } else { $rarr['st'] = 'err'; $rarr['err'] = "無價格,請連絡資訊人員!"; } } else if ($source == "M") { $db_query = "select id, price_a_1 from facility_maintenance_price where kind = '$kind' and seat = '$seat' and numberofstop = '$numberofstop' "; $db_query .= "and speed = '$speed' and status = 'Y'"; //echo $db_query;exit; $res = mysqli_query($link, $db_query); if ($row = mysqli_fetch_row($res)) { $id = $row[0]; $price = $row[1]; } mysqli_free_result($res); if (!empty($id)) { $rarr["id"] = $id; $rarr["amt"] = $price; } else { $rarr['st'] = 'err'; $rarr['err'] = "無價格,請連絡資訊人員!"; } } }catch(\Exception $e) { $rarr['st'] = 'err'; $rarr['err'] = $e->getMessage(); } //print_r($rarr);exit; echo json_encode($rarr, JSON_UNESCAPED_UNICODE); exit; ?>