-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview_data.php
executable file
·121 lines (95 loc) · 2.92 KB
/
view_data.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
<?php
session_start();
//print_r($_POST);
include 'common.php';
if(!login_varify())
{
exit();
}
main_menu();
function view_dataa($id)
{
$link=start_nchsls();
if(!$result_id=mysql_query('select * from view_data where id=\''.$id.'\'',$link)){echo mysql_error();}
$array_id=mysql_fetch_assoc($result_id);
$sql=$array_id['sql'];
$info=$array_id['info'];
////modify sql
if(strlen($_POST['__p1'])>0){$sql=str_replace('__p1',$_POST['__p1'],$sql);$info=$info.' ['.$_POST['__p1'].'] ';}
if(strlen($_POST['__p2'])>0){$sql=str_replace('__p2',$_POST['__p2'],$sql);$info=$info.' ['.$_POST['__p2'].'] ';}
if(strlen($_POST['__p3'])>0){$sql=str_replace('__p3',$_POST['__p3'],$sql);$info=$info.' ['.$_POST['__p3'].'] ';}
if(strlen($_POST['__p4'])>0){$sql=str_replace('__p4',$_POST['__p4'],$sql);$info=$info.' ['.$_POST['__p4'].'] ';}
//////////////
// echo $sql;
$first_data='yes';
if(!$result=mysql_query($sql,$link)){echo mysql_error();}
echo '<table border=1><tr><th colspan=20 bgcolor=lightblue>'.$info.'</th></tr>';
$first_data='yes';
while($array=mysql_fetch_assoc($result))
{
if($first_data=='yes')
{
echo '<tr bgcolor=lightgreen>';
foreach($array as $key=>$value)
{
echo '<th>'.$key.'</hd>';
}
echo '</tr>';
$first_data='no';
}
foreach($array as $key=>$value)
{
echo '<td>'.$value.'</td>';
}
echo '</tr>';
}
echo '</table>';
}
function get_sql()
{
$link=start_nchsls();
if(!$result=mysql_query('select * from view_data',$link)){echo mysql_error();}
echo '<form method=post>';
echo '<table border=1><tr><th colspan=20>Select the data to view</th></tr>';
echo '<tr>
<td>__p1:<input type=text name=__p1></td>
<td>__p2:<input type=text name=__p2></td>
<td>__p3:<input type=text name=__p3>
__p4:<input type=text name=__p4></td>
</tr>';
$first_data='yes';
while($array=mysql_fetch_assoc($result))
{
if($first_data=='yes')
{
echo '<tr>';
foreach($array as $key=>$value)
{
echo '<th bgcolor=lightgreen>'.$key.'</th>';
}
echo '</tr>';
$first_data='no';
}
foreach($array as $key=>$value)
{
if($key=='id')
{
echo '<td><input type=submit name=id value=\''.$value.'\'></td>';
}
else
{
echo '<td>'.$value.'</td>';
}
}
echo '</tr>';
}
echo '</table>';
echo '</form>';
}
echo '<h2 style="page-break-before: always;"></h2>';
if(isset($_POST['id']))
{
view_dataa($_POST['id']);
}
get_sql();
?>