-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread.php
66 lines (57 loc) · 1.78 KB
/
read.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
<?php
$host = 'localhost';
$user = 'root';
$pass = '';
$dbname = 'option_DB';
$conn = mysqli_connect($host, $user, $pass, $dbname);
if (!$conn) {
die('Could not connect: ' . mysqli_connect_error());
}
$filter = '';
if (isset($_GET['option']) && !empty($_GET['option'])) {
$filter .= ' AND option = "' . $_GET['option'] . '"';
}
if (isset($_GET['type']) && !empty($_GET['type'])) {
$filter .= ' AND type = "' . $_GET['type'] . '"';
}
if (isset($_GET['name']) && !empty($_GET['name'])) {
$filter .= ' AND name = "' . $_GET['name'] . '"';
}
$query = "SELECT * FROM option WHERE 1" . $filter;
$result = mysqli_query($conn, $query);
?>
<!DOCTYPE html>
<html>
<head>
<title>Option Administration Page</title>
</head>
<body>
<h2 align="center">Option Administration Page</h2>
<p align="center"><a href="insert_view.php">Add New</a></p><br><br>
<form action="read.php" method="get" align="center">
Option#: <input type="text" name="option" value="<?php echo isset($_GET['option']) ? $_GET['option'] : '' ?>">
Type: <input type="text" name="type" value="<?php echo isset($_GET['type']) ? $_GET['type'] : '' ?>">
Name <input type="text" name="name" value="<?php echo isset($_GET['name']) ? $_GET['name'] : '' ?>">
<input type="submit" value="Submit">
<br><br>
</form>
<table border="1" align="center" >
<tr >
<th>Option#</th>
<th>Type</th>
<th>Name</th>
<th>edit</th>
<th>delete</th>
</tr>
<?php while ($row = mysqli_fetch_array($result)) : ?>
<tr>
<td><?php echo $row['option']; ?></td>
<td><?php echo $row['type']; ?></td>
<td><?php echo $row['name'] ?></td>
<td><a href="upadate_view.php?id=<?php echo ($row['id']) ?>">Edit</a></td>
<td><a href="delete.php?id=<?php echo ($row['id']) ?>">Delete</a></td>
</tr>
<?php endwhile; ?>
</table>
</body>
</html>