-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
162 lines (118 loc) · 3.76 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
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
<?php
ob_start();
session_start();
// Create database connection using config file
include_once("config.php");
// Fetch all users data from database
$result = mysqli_query($mysqli, "SELECT * FROM users ORDER BY id DESC");
?>
<?php
require("header.php");
?>
<div class = "card">
<?php if(isset($_SESSION['success']) && !empty($_SESSION['success'])) : ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<strong><?= $_SESSION['success'] ?></strong> .
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<?php elseif(isset($_SESSION['error']) && !empty($_SESSION['error'])): ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong><?= $_SESSION['error'] ?></strong> .
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<?php endif ?>
<div class = "card-header">
<!-- <div class="text-left">
<a class="btn btn-primary" href="index.html" role="button">Home</a>
</div> -->
<div class="card-body">
<div class="text-right">
<button type="button" class="fa fa-user-plus btn btn-primary" data-toggle="modal" data-target="#exampleModal">
User
</button>
</div>
</div>
</div>
<div class = "card-body">
<table class="table table-bordered table-sm" id="mydatatable">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Name</th>
<th scope="col">E-mail</th>
<th scope="col">Address</th>
<th scope="col">phone</th>
<th scope="col">View</th>
<th scope="col">Edit</th>
<th scope="col">Delete</th>
</tr>
</thead>
<?php
$n=0;
while($user_data = mysqli_fetch_array($result)) {
$n++;
echo "<tr>";
echo "<td>".$n."</td>";
echo "<td>".$user_data['name']."</td>";
echo "<td>".$user_data['email']."</td>";
echo "<td>".$user_data['address']."</td>";
echo "<td>".$user_data['phone']."</td>";
echo "<td style='width: 50px;'>
<a href='view.php?id=$user_data[id]' class='badge badge-primary btn-md fa fa-eye' role='button' > view</a>
</td>
<td>
<a href='edit.php?id=$user_data[id]' class='fa fa-pencil-square-o badge badge-success btn-md' role='button'> Edit</a>
</td>
<td>
<a href='delete.php?id=$user_data[id]' class='badge badge-danger btn-md fa fa-trash-o ' role='button'> Delete</a>
</td>
</tr>";
}
?>
</table>
</div>
</div>
</body>
</html>
<?php
include_once("config.php");
// Fetch all users data from database
$result = mysqli_query($mysqli, "SELECT * FROM users ORDER BY id ASC");
?>
<body>
<?php
if(isset($_GET['id'])){
$id = $_GET["id"];
include_once ("config.php");
$result=mysqli_query($mysqli,"SELECT *FROM users WHERE id=$id");
$row = mysqli_fetch_array($result);
?>
<div class="row">
<div class="col"><h5>Name:</h5></div>
<div class="col"><p><?php echo $row["name"]; ?></p></div>
<div class="col"><h5>E-mail:</h5></div>
<div class="col"> <p><?php echo $row["email"]; ?></p></div>
<div class="w-100"></div>
<div class="col"><h5>Address:</h5></div>
<div class="col"> <p><?php echo $row["address"]; ?></p></div>
<div class="w-100"></div>
<div class="col"> <h5>Phone:</h5></div>
<div class="col"> <p><?php echo $row["phone"]; ?></p></div>
<div class="w-100"></div>
</div>
<?php
}
?>
</div>
</div>
<?php
session_unset();
require_once('add.php')
?>
<?php include_once('footer.php') ?>
</body>
</html>