-
Notifications
You must be signed in to change notification settings - Fork 0
/
week7(shoppingcart).php
90 lines (76 loc) · 1.64 KB
/
week7(shoppingcart).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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>購物車</title>
<style>
.td_align {text-align: right}
</style>
</head>
<body bgcolor="#FFDDAA">
</body>
</html>
<?php
session_start();
echo "<table>";
echo "<tr bgcolor='#9955FF'>";
echo "<td>功能</td>";
echo "<td>編號</td>";
echo "<td>名稱</td>";
echo "<td>價格</td>";
echo "<td>數量</td>";
echo "</tr>";
$flag = ' ';
$date = strtotime("+7 days", time());
$total = 0;
while (list($arr, $value) = each($_COOKIE))
{
if (isset($_COOKIE[$arr]) && is_array($_COOKIE[$arr]))
{
if ($flag)
{
$flag = false;
$color = "#FF99CC";
}
else
{
$flag = true;
$color = "#99FFC";
}
echo "<tr bgcolor='" . $color . "'><td>";
echo "<a href='homework3(delete).php?Id=" . $arr . "'>";
echo "刪除</a></td>";
$price = 0;
$quantity = 0;
while (list($name, $value)=each($_COOKIE[$arr]))
{
echo "<td>" . $value . "</td>";
if ($name == "price")
{
$price = $value;
}
else if ($name == "quantity")
{
$quantity = $value;
}
}
$total += $price * $quantity;
}
echo "</tr>";
}
echo "<tr bgcolor='#FFFF00' class='td_align'>";
echo "<td colspan='5'>";
echo "總金額 = NT$";
echo $total;
echo "元</td>";
echo "</tr>";
echo "</table>";
echo "<br>";
echo "<a href='homework3(list)-A1043338.php'>商品目錄</a></td>";
echo " ";
echo " ";
echo "<a href='homework3(shoppingcart).php'>檢視購物車</a></td>";
echo " ";
echo " ";
echo "<a href='homework3(result).php'>確定送出</a></td>";
?>