-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.php
166 lines (132 loc) · 4.19 KB
/
display.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
<?php
session_start();
// if(isset($_SESSION['email'])) {
// echo "Welcome ".$_SESSION['email'];
// } else {
// echo "Welcome Guest!";
// }
?>
<html>
<head>
<title>Display Page</title>
<style>
body {
background: rgb(144, 250, 58);
}
h1{
margin: 20px 38%;
text-align: center;
border-radius: 15px;
background: #004f63;
color: #fff;
font-family: arial;
}
table {
background: #fff;
border-radius: 10px;
margin: 10px auto;
width: 100%;
}
.edit_btn, .delete_btn {
background: green;
color: #fff;
width: 45%;
height: 25px;
font-weight: bold;
cursor: pointer;
border: 0;
border-radius: 7px;
outline: none;
margin: 2px;
}
.delete_btn {
background: red;
}
.logout_btn input{
background: purple;
color: #fff;
width: 80px;
height: 25px;
border-radius: 7px;
cursor: pointer;
margin-top: 20px;
margin-left: 45%;
}
</style>
</head>
<?php
include ("connection.php");
error_reporting(0);
$userprofile = $_SESSION['email'];
if($userprofile == true) {
}else {
header('location:login.php');
}
$query = "SELECT * FROM form";
$data = mysqli_query($conn, $query);
$show_data = mysqli_num_rows($data);
// bring data in array format and store in one variable
// $result = mysqli_fetch_assoc($data);
// echo $result['lname'];
// echo $result['address'];
// echo $result['fname'] . " " . $result['lname'] . " " . $result['gender'] . " " . $result['email'] . " " . $result['phone'] . " " . $result['address'];
// echo $show_data;
if($show_data != 0) {
// echo " <br> Table has records";
// $a = 1;
?>
<h1>Display Data Page</h1>
<table border= 2 cellspacing = 6>
<tr>
<th width="3%">ID</th>
<th width="3%">Image</th>
<th width="8%">First Name</th>
<th width="8%">Last Name</th>
<th width="7%">Gender</th>
<th width="10%">Email</th>
<th width="8%">Phone</th>
<th width="6%">Degree</th>
<th width="10%">Language</th>
<th width="15%">Address</th>
<th width="10%">Actions</th>
</tr>
<?php
while($result = mysqli_fetch_assoc($data)) {
// echo $result['fname'] . " " . $result['lname'] . " " . $result['gender'] . " " . $result['email'] . " " . $result['phone'] . " " . $result['address'] . "<br>";
// echo "<br> $a Hello I'm using while loop here!";
// $a++;
echo "<tr>
<td>".$result['id']."</td>
<td><img src= '".$result['img_file']."' height='50px; width=50px;'></td>
<td>".$result['fname']."</td>
<td>".$result['lname']."</td>
<td>".$result['gender']."</td>
<td>".$result['email']."</td>
<td>".$result['phone']."</td>
<td>".$result['degree']."</td>
<td>".$result['language']."</td>
<td>".$result['address']."</td>
<td>
<a href='update.php?id=$result[id]'>
<input type='submit' value='Edit' class='edit_btn'>
</a>
<a href='delete.php?id=$result[id]'>
<input type='submit' value='Delete' class='delete_btn' onclick= 'return checkdelete()'>
</a>
</td>
</tr>";
}
} else {
echo "No record found!";
}
?>
</table>
<div class="logout_btn">
<a href="logout.php"><input type="submit" value="Logout" name="logout_btn"></a>
</div>
</html>
<script>
function checkdelete() {
return confirm(' Do you really want to delete this entry? ');
}
</script>