-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cart_0716.php
More file actions
59 lines (53 loc) · 1.51 KB
/
test_cart_0716.php
File metadata and controls
59 lines (53 loc) · 1.51 KB
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
49
50
51
52
53
54
55
56
57
58
59
<?php
require_once '../mobile/dbconnect_utf.php';
$uid=63;
$cart=getCartByUid($uid);
$cartId=$cart['id'];
$cart=getCartDetailByCid($cartId);
echo json_encode($cart);
function getUserInfoByUid($uid){
$sql=sprintf("select * from blog_express_customer where customer_id='%d'",$uid);
$result=mysql_query($sql);
if($result){
$row=mysql_fetch_array($result);
}
return $row;
}
function getCartByUid($uid){
$sql=sprintf("select * from blog_cart where user_id='%d'",$uid);
$result=mysql_query($sql);
if($result){
$row=mysql_fetch_array($result);
}
return $row;
}
function getCartDetailByCid($uid){
$sql=sprintf("select * from blog_cart_detail where cid='%d'",$uid);
$result=mysql_query($sql);
if($result){
$cart=array();
$temp=array();
$totalMoney=0;
while($row=mysql_fetch_array($result)){
$productInfo=getProductInfo($row['pid']);
$temp['pid']=$row['pid'];
$temp['subject']=$productInfo['subject'];
$temp['F_Price']=$productInfo['F_Price'];
$temp['goods_attr']=$row['goods_attr'];
$temp['count']=$row['count'];
$totalMoney+=$temp['F_Price'];
$cart[]=$temp;
}
$cart['totalMoney']=$totalMoney;
}
return $cart;
}
function getProductInfo($pid){
$sql=sprintf("select * from blog_article where aid='%d'",$pid);
$result=mysql_query($sql);
if($result){
$row=mysql_fetch_array($result);
}
return $row;
}
?>