-
Notifications
You must be signed in to change notification settings - Fork 0
/
memberCouponInfo.php
44 lines (32 loc) · 1.17 KB
/
memberCouponInfo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
try {
if ($_SERVER['HTTP_HOST'] == 'localhost' || $_SERVER['HTTP_HOST'] == '127.0.0.1') {
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Content-Type");
header("Content-Type: application/json; charset=UTF-8");
require_once("connectPxzoo.php");
} else {
require_once("connect_chd104g4.php");
}
// 檢查是否有收到會員ID
if (isset($_GET['mem_id'])) {
$mem_id = $_GET['mem_id'];
$sql = 'SELECT cd.*, c.cou_pic FROM coupon_detail cd
LEFT JOIN coupon c ON cd.cou_id = c.cou_id
WHERE cd.mem_id = ?;';
$memOrder = $pdo->prepare($sql);
$memOrder->bindValue(1, $mem_id);
$memOrder->execute();
$result = $memOrder->fetchAll(PDO::FETCH_ASSOC);
if ($memOrder->rowCount() > 0) {
echo json_encode($result);
} else {
echo json_encode(["errMsg" => "尚無優惠券"]);
}
} else {
echo json_encode(["errMsg" => "未提供ID"]);
}
} catch (PDOException $e) {
echo json_encode(["errMsg" => "執行失敗: " . $e->getMessage()]);
}
?>