-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.php
More file actions
119 lines (114 loc) · 2.15 KB
/
view.php
File metadata and controls
119 lines (114 loc) · 2.15 KB
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
<?php
session_start();
$out=$ouput='';
$x=$_SESSION['user'];
$conn = mysqli_connect('localhost','root','Aa#123','datastorage');
$users = [];
$result = mysqli_query($conn,"select column_name from information_schema.columns where table_name='userp".$x."'");
while ($row = $result->fetch_assoc()) {
$users[] = $row;
}
$flag=0;
$i=0;
foreach($users as $user)
{
if($flag==0)
$flag=1;
else
{
$out.='<br>'.$user['column_name']." : <input type='text' name='c".$i."'><br>";
$i++;
$_SESSION['number']=$i;
}
}
if(isset($_POST['view']))
{
$n=$_SESSION['number'];
$users = [];
$result = mysqli_query($conn,"select column_name from information_schema.columns where table_name='userp".$x."'");
while ($row = $result->fetch_assoc()) {
$users[] = $row;
}
$flag=0;
$i=0;
$addup='';
foreach($users as $user)
{
if($flag==0)
$flag=1;
else
{
//$out.='<br>'.$user['column_name']." : <input type='text' name='c".$i."'><br>";
$o=$user['column_name'];
$a=$_POST["c".$i];
if($a!='')
$addup.=$o."='".$a."' AND ";
$i++;
}
}
$addup.="TRUE";
$details = [];
$result=mysqli_query($conn,"SELECT * FROM userp".$x." WHERE ".$addup);
while ($row = $result->fetch_assoc()) {
$details[] = $row;
}
$output='';
foreach($details as $detail)
{
$flag=0;
foreach($users as $user)
{
if($flag==0)
$flag=1;
else
{
$o=$user['column_name'];
$output.=$detail[$o]." ";
}
}
$output.="<br>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Add</title>
<style>
body
{
background-color:grey;
padding : 0px 0px 150px 0px;
}
form
{
background-color:white;
width:20%;
padding : 10px 20px 10px 20px;
font-size:25px;
}
label
{
font-size:30px;
}
input
{
font-size : 20px;
}
#submit
{
background-color:lightgreen;
width:100%;
}
</style>
</head>
<body>
<center>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php echo $out; ?>
<br><input type="submit" name="view" value="View" id="submit"><br>
<?php echo $output; ?>
</form>
</center>
</body>
</html>