-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomers.php
More file actions
159 lines (147 loc) · 5.14 KB
/
Customers.php
File metadata and controls
159 lines (147 loc) · 5.14 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
window.onload = function(){
$("#add") .hide();
$("#delete").hide();
$("#update").hide();
}
$(document).ready(function(){
$("#showAdd").click(function(){
$("#add").show();
$("#delete").hide();
$("#update").hide();
});
$("#showDelete").click(function(){
$("#add").hide();
$("#delete").show();
$("#update").hide();
});
$("#showUpdate").click(function(){
$("#add").hide();
$("#delete").hide();
$("#update").show();
});
});
</script>
</head>
<header>
<h3><a href="index.php">Back</a><h3>
</header>
<body>
<form action="Customers.php" method="post">
<input type="search" name="search" placeholder="Search..">
</form>
<?php
include "db.php";
//include "loginform.php";
// Create connection
//$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
//if ($conn->connect_error) {
// die("Connection failed: " . $conn->connect_error);
//}
//$staffView = "CREATE VIEW staffView AS SELECT staffID,sFname, sSurname, position, salary , sAddress, sCity, sPostcode, sEmail, sPhoneNumber, branchID FROM staff WHERE ID = '$_SESSION['ID']'";
//$managerView = "CREATE VIEW managerView AS SELECT staffID,sFname, sSurname, position, salary , sAddress, sCity, sPostcode, sEmail, sPhoneNumber, branchID FROM staff";
$order = isset($_GET['sort'])?$_GET['sort']:'customerID';
error_reporting(0);
$id = $_POST["search"];
if($id==null)
{
$sql = "SELECT customerID, cFname, cSurname, cAddress, cCity, cPostcode, cEmail, cPhoneNumber FROM customer ORDER BY $order";
}
else
{
$sql = "SELECT customerID, cFname, cSurname, cAddress, cCity, cPostcode, cEmail, cPhoneNumber FROM customer where customerID='$id' or cFname='$id' or cSurname='$id' or cAddress='$id' or cCity='$id' or cPostcode='$id' ORDER BY '$order'";
}
$result = mysql_query($sql, $db);
echo "<table width = '100%' class='demo'>
<caption><h2>Customers</h2></caption>
<tr>
<th><a href='Customers.php?sort=customerID'>ID</a></th>
<th><a href='Customers.php?sort=cFname'>First name</a></th>
<th><a href='Customers.php?sort=cSurname'>Last name</a></th>
<th><a href='Customers.php?sort=cAddress'>Address</a></th>
<th><a href='Customers.php?sort=cCity'>City</a></th>
<th><a href='Customers.php?sort=cPostcode'>Postcode</a></th>
<th><a href='Customers.php?sort=cPhoneNumber'>Phone number</a></th>
<th><a href='Customers.php?sort=cEmail'>Email</a></th>
</tr>";
while($row = mysql_fetch_array($result)) {
echo "<tr> <td>" . $row["customerID"] . "</td> <td>" . $row["cFname"] . "</td> <td>" . $row["cSurname"] . "</td> <td>" .
$row["cAddress"] . "</td> <td>" . $row["cCity"] . "</td> <td>" .$row["cPostcode"] . "</td> <td>" . $row["cPhoneNumber"] . "</td> <td>" .
$row["cEmail"];
echo " </td></tr>";
// echo "<a href = 'index.php/". $row["staffID"] ."'>" . "id: " . $row["staffID"]. " - Name: " . $row["sFname"]. " " . $row["sSurname"]. "<br>" . "</a>";
}
echo " </table>"
?>
<br>
<br>
<table width="100%">
<tr>
<td width = "33.3%" align="center"><button id="showAdd">Add Customer</button></td>
<td width = "33.3%" align="center"><button id="showDelete">Delete Customer</button></td>
<td width = "33.3%" align="center"><button id="showUpdate">Update Customer</button></td>
</tr>
<tr >
<td width = "33.3%" align="center">
<form name="Add customer member" action="AddCustomerForm.php" method="post" id = "add" class="center">
<div class="field">
<label>Firstname</label>
<input type="text" name="firstname"><br>
<label>Surname</label>
<input type="text" name="surname"><br>
<label>Address</label>
<input type="text" name="address"><br>
<label>City</label>
<input type="text" name="city"><br>
<label>Postcode</label>
<input type="text" name="postcode"><br>
<label>Email</label>
<input type="text" name="email"><br>
<label>Phone Number</label>
<input type="text" name="phonenumber"><br>
<input type="submit" value="Submit">
</div>
</form>
</td>
<td width = "33.3%" align="center">
<form name="Delete customer member" action="DeleteCustomerForm.php" method="post" id = "delete" class="center">
<div class="field">
<label>ID (Unique)</label>
<input type="text" name="id"><br>
<label>Last name</label>
<input type="text" name="lastname"><br>
<input type="submit" value="Submit">
</div>
</form>
<td width = "33.3%" align="center">
<form name="Update Customer" action="UpdateCustomerForm.php" method="post" id = "update" class="center">
<div class="field">
<label>ID (Unique)</label>
<input type="text" name="id"><br>
<label>Firstname</label>
<input type="text" name="firstname"><br>
<label>Surname</label>
<input type="text" name="surname"><br>
<label>Address</label>
<input type="text" name="address"><br>
<label>City</label>
<input type="text" name="city"><br>
<label>Postcode</label>
<input type="text" name="postcode"><br>
<label>Email</label>
<input type="text" name="email"><br>
<label>Phone Number</label>
<input type="text" name="phonenumber"><br>
<input type="submit" value="Submit">
</div>
</form>
</td>
</tr>
</table>
</body>
</html>