-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
133 lines (115 loc) · 2.51 KB
/
admin.php
File metadata and controls
133 lines (115 loc) · 2.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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php session_start();
define('DB_SERVER','localhost');
define('DB_USERNAME','root');
define('DB_PASSWORD','');
define('DB_DATABASE','demo');
class user
{
public $db;
public function __construct()
{
$this->db=new mysqli(DB_SERVER,DB_USERNAME,DB_PASSWORD,'demo');
if(mysqli_connect_errno())
{
echo "Error: Could not connect to database.";
exit;
}
}
public function get_session()
{
return $_SESSION['login'];
}
public function user_logout()
{
$_SESSION['login']=false;
session_destroy();
}
}
$user=new User();
$uid=$_SESSION['uid'];
if(!$user->get_session())
{
header("location:user/user_login.php");
}
if(isset($_GET['q']))
{
$user->user_logout();
header("location:login.php");
}
$qt1 = 0; $qt2 = 0;
$w1 = 0; $w2 = 0;
$b1 = 0; $b2 = 0;
//customer 1
$sql1 = "SELECT * FROM customer WHERE p_key=2";
$r = mysqli_query($user->db,$sql1);
while($row = mysqli_fetch_array($r))
{
$qt1 += $row['qnty'];
$w1 += $row['weight'];
$b1 += $row['box_cnt'];
}
//customer 2
$sql1 = "SELECT * FROM customer WHERE p_key=3";
$r = mysqli_query($user->db,$sql1);
while($row = mysqli_fetch_array($r))
{
$qt2 += $row['qnty'];
$w2 += $row['weight'];
$b2 += $row['box_cnt'];
}
// echo "<script>alert('r=".$qt1."qt2=".$qt2."')</script>";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<style>
th, td{
padding:3px 20px;
text-align:center;
}
td{
background-color:light
}
.r2{
background-color:cyan
}
th{
background-color:skyblue;
}
.th1{
background-color:yellow;
}
</style>
</head>
<body>
<form action="" method="post" name="customer">
<table border = 3>
<tr>
<th class = 'r2'>Item/Customer</th>
<th>Customer1</th>
<th>Customer2</th>
<th>Total</td>
</tr>
<tr>
<th class = "th1">Quantity</th>
<td><?php echo $qt1 ?></td>
<td><?php echo $qt2 ?></td>
<td><?php echo $qt1 + $qt2 ?></td>
</tr>
<tr class = 'r2'>
<th class = "th1">Weight</th>
<td><?php echo $w1 ?></td>
<td><?php echo $w2 ?></td>
<td><?php echo $w1+$w2 ?></td>
</tr>
<tr>
<th class = "th1">Box count</th>
<td><?php echo $b1 ?></td>
<td><?php echo $b2 ?></td>
<td><?php echo $b1+$b2 ?></td>
</tr>
</table>
<br>
</form>
</body>
</html>