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