-
Notifications
You must be signed in to change notification settings - Fork 0
/
select.php
167 lines (145 loc) · 6.16 KB
/
select.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
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
160
161
162
163
164
165
166
167
<?php include 'dbconnect.php' ?>
<!DOCTYPE html>
<html>
<head>
<title>Select Records</title>
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Source+Code+Pro'>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="project-team19.css">
<style> body {font-family: 'Source Code Pro', sans-serif; color: black;} </style>
</head>
<div style="text-align:center;">
<body>
<div class="menu-bar">
<div>
<a href="index.php"><img id="logo" src="logo.png"></a>
</div>
<div>
<a href="index.php">Home</a>
</div>
<div>
<a href="types_of_services.php">Types Of Services</a>
</div>
<div>
<a href="reviews.php">Reviews</a>
</div>
<div>
<a href="shopping_cart.php">Shopping Cart</a>
</div>
<div>
<a href="about_us.php">About Us</a>
</div>
<div>
<a href="contact_us.php">Contact Us</a>
</div>
<div class="dropdown">
<button class="dropbtn">DB Maintain</button>
<div class="dropdown-content">
<a href="insert.php">Insert</a>
<a href="delete.php">Delete</a>
<a href="select.php">Select</a>
<a href="update.php">Update</a>
</div>
</div>
<div>
<a href="logout.php">Log Out</a>
</div>
</div>
<h1 style="text-align:center;">Select Records</h1>
<form action="" method="post">
<p>Select Table to Search From:<p>
<select name="table">
<option value="orders">Orders</option>
<option value="items">Items</option>
<option value="users">Users</option>
<option value="trip">Trip</option>
<option value="truck">Truck</option>
<option value="stock">Stock</option>
<option value="payment">Payment</option>
</select>
<p>Type in the id to Search From Table:<p>
<input type="text" id="item" name="item"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</div>
</html>
<?php
require __DIR__ . './functions.php';
if (isset($_POST['submit'])) {
if ($_POST['table'] === 'orders') {
$item = $_POST['item'];
$result = $connect -> query("SELECT * from orders WHERE order_id=$item;");
if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
echo "Order ID: " . $row["order_id"] . "<br>Trip ID: " . $row["trip_id"] . "<br>receipt ID: "
. $row["receipt_id"] . "<br>User ID: " . $row["user_id"] . "<br>Branch: " . $row["branch"]
. "<br>Date Issued: " . $row["date_issued"] . "<br>Date Received: " . $row["date_recieved"]
. "<br>Total Price: " . $row["total_price"];
}
else echo "No entry found.";
}
if ($_POST['table'] === 'items') {
$item = $_POST['item'];
$result = $connect -> query("SELECT * from items WHERE item_id=$item;");
if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
echo "Item ID: " . $row["item_id"] . "<br>Name: " . $row["name"] . "<br>Price: "
. $row["price"] . "<br>Quantity: " . $row["quantity"];
}
else echo "No entry found.";
}
if ($_POST['table'] === 'users') {
$item = $_POST['item'];
$result = $connect -> query("SELECT * from users WHERE user_id=$item;");
if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
echo "User ID: " . $row["user_id"] . "<br>Name: " . $row["name"] . "<br>Phone: "
. $row["tel_no"] . "<br>Email: " . $row["email"] . "<br>Address: " . $row["address"]
. "<br>Login ID: " . $row["login_id"] . "<br>Password: " . $row["password"]
. "<br>Balance: " . $row["balance"];
}
else echo "No entry found.";
}
if ($_POST['table'] === 'trip') {
$item = $_POST['item'];
$result = $connect -> query("SELECT * from trip WHERE trip_id=$item;");
if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
echo "Trip ID: " . $row["trip_id"] . "<br>Truck: " . $row["truck_id"] . "<br>Distance: "
. $row["distance"] . "<br>Branch: " . $row["branch"] . "<br>Destination: " . $row["destination"];
}
else echo "No entry found.";
}
if ($_POST['table'] === 'truck') {
$item = $_POST['item'];
$result = $connect -> query("SELECT * from truck WHERE truck_id=$item;");
if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
echo "Truck ID: " . $row["truck_id"] . "<br>Truck Code: " . $row["truck_code"]
. "<br>Avaialble: " . $row["available"];
}
else echo "No entry found.";
}
if ($_POST['table'] === 'stock') {
$item = $_POST['item'];
$result = $connect -> query("SELECT * from stock WHERE stock_id=$item;");
if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
echo "Stock ID: " . $row["stock_id"] . "<br>Name: " . $row["name"] . "<br>Pirce: "
. $row["price"] . "<br>Quantity: " . $row["quantity"];
}
else echo "No entry found.";
}
if ($_POST['table'] === 'payment') {
$item = $_POST['item'];
$result = $connect -> query("SELECT * from payment WHERE user_id=$item;");
if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
echo "User ID: " . $row["user_id"] . "<br>CC Number: " . $row["cc_num"]
. "<br>CVV: " . $row["cvv"];
}
else echo "No entry found.";
}
}
?>