-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay.php
110 lines (86 loc) · 2.72 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
<!DOCTYPE html>
<html>
<head>
<title>Reflux | Database</title>
<style type="text/css">
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body style="background-color: #fafafa;">
<?php
$servername = "mysql.hostinger.in";
$username = "u932729557_admin";
$password = "Aks12345";
// Create connection
$connection = mysqli_connect($servername, $username, $password,"u932729557_main");
//create connection
//test if connection failed
if(mysqli_connect_errno()){
die("connection failed: "
. mysqli_connect_error()
. " (" . mysqli_connect_errno()
. ")");
}
//get results from database
$result = mysqli_query($connection,"show tables");
$all_property = array(); //declare an array for saving property
// //showing property
// echo '<table class="data-table">
// <tr class="data-heading">'; //initialize table tag
while ($property = mysqli_fetch_field($result)) {
// echo '<td>' . $property->name . '</td>'; //get field name for header
array_push($all_property, $property->name); //save those to array
}
echo '</tr>'; //end tr tag
echo '<form action="" method="post" >
<center><div style="border:2px solid #cacaca;border-radius:5px;background-color:#fafafa;width:40%;padding:9px 15px;">
Password : <input type="text" name="key"/><br/><br>
Select Table : <select name="table">';
while ($row = mysqli_fetch_array($result)) {
foreach ($all_property as $item) {
echo '<option value='.$row[$item] .'>'.$row[$item] .'</option><br>';
}
}
echo '</select><br/><br>
<input type="submit" name="submit" value="View" class="btn"/></center><br>
</form>';
if (isset($_POST['submit']))
{
if($_POST['key'] != "Reflux.1820"){
echo "Incorrect password.";
exit();
}
$table= $_POST['table'];
$result = mysqli_query($connection,"select * from `".$table."`");
$all_property = array(); //declare an array for saving property
echo '<table class="data-table">
<tr class="data-heading">'; //initialize table tag
while ($property = mysqli_fetch_field($result)) {
echo '<th>' . $property->name . '</th>'; //get field name for header
array_push($all_property, $property->name); //save those to array
}
echo '</tr>';
while ($row = mysqli_fetch_array($result)) {
echo '<tr>';
foreach ($all_property as $item) {
echo '<td>' .$row[$item]. '</td>';
}
echo '</tr>';
}
echo "</table>";
}
?>
</body>
</html>