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.
 
 
 
 
 
 

48 lines
1.1 KiB

<?php
/**
* 取得拆梯價目
* @url /pricereview_demolition-api.php
* @method POST
* @return JSON
*
* request
* {
* "fval"
* }
* fval : 樓層,人乘
* respons json
* {
* "st" : "ok",
* "err" : ""
* }
**/
ob_start();
include "../header.php";
ob_end_clean();
$rarr = array('st' => '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($floor, $seat) = explode(",", $fval);
if (!$floor || !$seat) throw new \Exception("parameter empty[2]");
$db_query = "select id, price from demolition_price where release_date = '2021-11-10' and seat = '$seat' and floor = '$floor' and status = 'Y'";
$res = mysqli_query($link, $db_query);
if ($row = mysqli_fetch_row($res)) {
$rarr["id"] = $row[0];
$rarr["amt"] = $row[1];
}
mysqli_free_result($res);
}catch(\Exception $e) {
$rarr['st'] = 'err';
$rarr['err'] = $e->getMessage();
}
echo json_encode($rarr, JSON_UNESCAPED_UNICODE);
exit;
?>