-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdated.html
151 lines (119 loc) · 3.96 KB
/
updated.html
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
<!DOCTYPE HTML>
<html>
<head>
<title>PDO - Read Records - PHP CRUD </title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="ordersStyle.css">
<link href="https://fonts.googleapis.com/css?family=Cookie|Josefin+Slab&display=swap" rel="stylesheet">
<!-- custom css -->
<style>
.m-r-1em{ margin-right:1em; }
.m-b-1em{ margin-bottom:1em; }
.m-l-1em{ margin-left:1em; }
.mt0{ margin-top:0; }
</style>
</head>
<style>
table {
width:100%;
}
body{
padding: 10px 20px 20px 20px;
margin: 10px;
}
table, th, td {
border: 1px solid #D8D6D0;
border-collapse: collapse;
padding: 15px;
width: 10%;
}
th, td {
padding: 5px;
text-align: left;
}
table#t01 tr:nth-child(even) {
background-color: #eee;
}
table#t01 tr:nth-child(odd) {
background-color: #fff;
}
table#t01 th {
background-color: #85DCB;
color: white;
}
</style>
<body>
<!-- container -->
<div class="container">
<!-- PHP code to read records will be here -->
<?php
// include database connection
include 'admin/php-beginner-crud-level-1/configs/database.php';
// delete message prompt will be here
$action = isset($_GET['action']) ? $_GET['action'] : "";
// if it was redirected from delete.php
if($action=='deleted'){
echo "<div class='alert alert-success'>Record was deleted.</div>";
}
// select all data
$query = "SELECT id, client,address FROM storage ORDER BY id DESC";
$stmt = $con->prepare($query);
$stmt->execute();
// this is how to get number of rows returned
$num = $stmt->rowCount();
// link to create record form
//check if more than 0 record found
if($num>0){
// data from database will be here
echo "<table class='table table-hover table-responsive table-bordered'>";//start table
//creating our table heading
echo "<tr>";
echo "<th>ID</th>";
echo "<th>Client</th>";
echo "<th>Address</th>";
echo "<th>Status</th>";
echo"<th>Extra Info</th>";
echo"<th> Action</th>";
echo "</tr>";
// table body will be here
// retrieve our table contents
// fetch() is faster than fetchAll()
// http://stackoverflow.com/questions/2770630/pdofetchall-vs-pdofetch-in-a-loop
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
// extract row
// this will make $row['firstname'] to
// just $firstname only
extract($row);
// creating new table row per record
echo "<tr>";
echo "<td>{$id}</td>";
echo "<td>{$client}</td>";
echo "<td>{$address}</td>";
echo "<td>";
// read one record
// we will use this links on next part of this post
echo "<button type='submit datetime-local' class='btn btn-primary m-r-1em button' name='starttime'>Send</button>";
// we will use this links on next part of this post
echo "</td>";
echo "</tr>";
}
// end table
echo "</table>";
}
// if no records found
else{
echo "<div class='alert alert-danger'>No records found.</div>";
}
?>
</div> <!-- end .container -->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<!-- Latest compiled and minified Bootstrap JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- confirm delete record will be here -->
</body>
</html>