-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshopping-kart.php
84 lines (76 loc) · 1.82 KB
/
shopping-kart.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
<?php
require_once( "templates.inc.php");
printHtmlTop("XYZ Shopping Cart");
printDefaultStyles();
?>
<style type="text/css">
#cart-list{
margin: 0 auto;
width: 550px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
<?php displayjQuerySetRedirect(); ?>
//jquery code here ...
});
</script>
</head>
<body>
<?php
printContainerTop(true);
session_start();
function getPurshaseOrder(){
if (isset($_SESSION['user_id'])){
$user = $_SESSION['user_id'];
}else{
$user = 1;
}
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xyz_shopping", $con);
$sql="SELECT * FROM purchase_order WHERE user='".$user."'";
$result = mysql_query($sql,$con);
$cnt = 0;
?>
<table id="cart-list" cellpadding="0" cellpadding="0">
<thead>
<tr>
<th>Name</th>
<th>Quantity</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
$sql="SELECT name FROM item WHERE id='".$row[2]."'";
$item_result = mysql_query($sql,$con);
$item_name = "";
while ($item_row = mysql_fetch_array($item_result, MYSQL_NUM)){
$item_name = $item_row[0];
}
?>
<tr>
<td><?php echo $item_name; ?></td>
<td><?php echo $row[3]; ?></td>
<td><?php echo $row[4]; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
getPurshaseOrder();
?>
<?php
printContainerBottom();
?>
<?php
printHtmlBottom();
?>