-
Notifications
You must be signed in to change notification settings - Fork 0
/
favorite_action.php
48 lines (42 loc) · 1.29 KB
/
favorite_action.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
44
45
46
47
48
<?php
header("Content-type: text/html; charset=utf-8");
require_once './lib/mysql.func.php';
session_start();
$uid = $_SESSION['uid'];
$action = $_REQUEST['action'];
$pro_id = $_REQUEST['pro_id'];
switch ($action) {
case 'add':
//add favorite items
$query = " replace into BS_Favorite(uid,pro_id,entrydate)";
$query .= " values($uid,$pro_id,now())";
// echo "$query";
mysqli_query(connect(), $query);
echo "收藏成功,可以在我的收藏中查看.";
break;
case 'delete':
//remove favorite item
$query = " delete from BS_Favorite where uid=$uid and pro_id=$pro_id";
mysqli_query(connect(), $query);
echo "删除成功";
break;
case 'show':
//show user favorite
$rows = array();
$query = " select P.pro_id ,title ,img_url ,detail_url ,shop_name ,price ,month_sold ,comm_percent ,seller_ww ,back_BB ,";
$query .= " short_tbk_url ,tbk_url ,commission ,earn ,img_list ,show_order ,P.cat_id ,C.entrydate ,disabled ";
$query .= " from BS_ProInfo AS P";
$query .= " join BS_Favorite as C on P.pro_id=C.pro_id";
$query .= " where P.disabled=0 and C.uid=$uid";
// $query .= " limit 30";//TODO add paging
// echo "$query";
$result = mysqli_query(connect(), $query);
while (@$row = mysqli_fetch_assoc($result)) {
$rows[] = $row;
}
echo json_encode($rows);
break;
default:
# code...
break;
}