01.
</pre>
02.
03.
04.
<?php
05.
require_once
(
"db_connect.php"
);
06.
07.
if
(
$_POST
[
"send1"
] !=
""
) {
08.
$_POST
[
"query"
] =
$_POST
[
"query1"
];
09.
}
10.
if
(
$_POST
[
"send2"
] !=
""
) {
11.
$_POST
[
"query"
] =
$_POST
[
"query2"
];
12.
}
13.
if
(
$_POST
[
"send3"
] !=
""
) {
14.
$_POST
[
"query"
] =
$_POST
[
"query3"
];
15.
}
16.
17.
if
(
$_POST
[
"query"
] !=
""
) {
18.
19.
20.
$result
=
$mysqli
->query(
$_POST
[
"query"
] );
21.
if
(
$result
!== FALSE ) {
22.
23.
24.
$field
= @
$result
->fetch_fields( );
25.
26.
$a
=
""
;
27.
28.
$a
.=
"<tr>"
;
29.
for
(
$i
= 0;
$i
<
count
(
$field
);
$i
++ ) {
30.
31.
$a
.=
"<td>{$field[$i]->name}</td>"
;
32.
33.
}
34.
$a
.=
"</tr>"
;
35.
36.
37.
38.
$b
=
""
;
39.
40.
41.
while
(
$row
=
$result
->fetch_array( MYSQLI_BOTH ) ) {
42.
43.
$b
.=
"<tr>"
;
44.
for
(
$i
= 0;
$i
<
count
(
$field
);
$i
++ ) {
45.
46.
$b
.=
"<td>{$row[$i]}</td>"
;
47.
48.
}
49.
$b
.=
"</tr>"
;
50.
51.
}
52.
53.
}
54.
else
{
55.
56.
$c
=
$mysqli
->error;
57.
}
58.
59.
}
60.
61.
62.
63.
64.
$mysqli
->close();
65.
66.
?>
67.
68.
<div style=
"padding: 0px 0px 0px 30px;margin-top:-40px"
>
69.
<form method=
"post"
style=
"display:inline-block"
>
70.
<div style=
"display:inline-block"
>
71.
<textarea name=
"query1"
style=
"width:500px;height:250px;"
><?=
$_POST
[
"query1"
] ?></textarea>
72.
<br><input type=
"submit"
name=
"send1"
value=
"送信"
>
73.
</div>
74.
<div style=
"display:inline-block"
>
75.
<textarea name=
"query2"
style=
"width:500px;height:250px;"
><?=
$_POST
[
"query2"
] ?></textarea>
76.
<br><input type=
"submit"
name=
"send2"
value=
"送信"
>
77.
</div>
78.
<div style=
"display:inline-block"
>
79.
<textarea name=
"query3"
style=
"width:500px;height:250px;"
><?=
$_POST
[
"query3"
] ?></textarea>
80.
<br><input type=
"submit"
name=
"send3"
value=
"送信"
>
81.
</div>
82.
</form>
83.
84.
<div><b style=
"color:red"
><?=
$c
?></b></div>
85.
86.
<table
class
=
"table table-hover table-responsive"
style=
"margin-top:20px;"
>
87.
<?=
$a
?>
88.
<?=
$b
?>
89.
</table>
90.
91.
</div>