-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
137 lines (137 loc) · 5.9 KB
/
index.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
<?php
include 'model.php';
$database = new database();
?>
<html>
<head>
<meta charset="utf-8">
<title>Create Update Delete Data PostgreSQL</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head>
<body>
<div id="container">
<div class="card-group">
<div class="card">
<div class="card-body">
<h5 class="card-title">Please enter book information</h5>
<form action="controller.php?action=insert" method="POST">
<div class="form-group row">
<label class="col-sm-2 col-form-label">Title</label>
<div class="col-sm-10">
<input type="text" name="book_name" class="form-control" placeholder="Title">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Author</label>
<div class="col-sm-10">
<input type="text" name="author" class="form-control" placeholder="Author">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Publisher</label>
<div class="col-sm-10">
<input type="text" name="publisher" class="form-control" placeholder="Publisher">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Published</label>
<div class="col-sm-10">
<input type="date" name="date_published" class="form-control" placeholder="Published">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Price</label>
<div class="col-sm-10">
<input type="number" name="price" class="form-control" placeholder="Price">
</div>
</div>
<div class="form-group row">
<div class="offset-sm-2 col-sm-10">
<input type="submit" name="insert" class="btn btn-primary">
</div>
</div>
</form>
</div>
</div>
<div class="card">
<div class="card-body">
<h5 class="card-title">Books information list</h5>
<table class="table table-stripped">
<tr>
<th>Title</th>
<th>Author</th>
<th>Publisher</th>
<th>Published</th>
<th>Price</th>
<th>Action</th>
</tr>
<?php foreach ($database->select() as $value): ?>
<tr>
<td><?php echo $value[1]; ?></td>
<td><?php echo $value[2]; ?></td>
<td><?php echo $value[3]; ?></td>
<td><?php echo $value[4]; ?></td>
<td><?php echo $value[5]; ?></td>
<td>
<button type="button" class="btn btn-danger btn-sm" href="controller.php?action=delete&book_id=<?php echo $value[0];?>">Delete</button>
<button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#edit-<?php echo $value[0];?>">Edit</button>
<div class="modal" id="edit-<?php echo $value[0];?>">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="card-header">Please change book information</div>
<div class="modal-body">
<form action="controller.php?action=update" method="POST">
<input type="text" name="book_id" value="<?php echo $value[0]?>" hidden="hidden">
<div class="form-group row">
<label class="col-sm-3 col-form-label">Title</label>
<div class="col-sm-9">
<input type="text" name="book_name" class="form-control" placeholder="Title" value="<?php echo $value[1]?>">
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Author</label>
<div class="col-sm-9">
<input type="text" name="author" class="form-control" placeholder="Author" value="<?php echo $value[2]?>">
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Publisher</label>
<div class="col-sm-9">
<input type="text" name="publisher" class="form-control" placeholder="Publisher" value="<?php echo $value[3]?>">
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Published</label>
<div class="col-sm-9">
<input type="date" name="date_published" class="form-control" placeholder="Published" value="<?php echo $value[4]?>">
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Price</label>
<div class="col-sm-9">
<input type="number" name="price" class="form-control" placeholder="Price" value="<?php echo $value[5]?>">
</div>
</div>
<div class="form-group row">
<div class="offset-sm-3 col-sm-9">
<input type="submit" name="insert" class="btn btn-primary">
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>
</html>