01.
<form method=
"post"
>
02.
<textarea name=
"query"
style=
"width:800px;height:250px;"
><?=
$_POST
[
"query"
] ?></textarea>
03.
<input type=
"submit"
name=
"send"
value=
"送信"
>
04.
</form>
05.
06.
<?php
07.
require_once
(
"db_connect.php"
);
08.
09.
if
(
$_POST
[
"query"
] !=
""
) {
10.
11.
12.
13.
$result
=
$mysqli
->query(
$_POST
[
"query"
] );
14.
15.
16.
$field
=
$result
->fetch_fields( );
17.
18.
print
"<pre>"
;
19.
20.
21.
22.
23.
for
(
$i
= 0;
$i
<
count
(
$field
);
$i
++ ) {
24.
25.
print
$field
[
$i
]->name .
" "
;
26.
27.
}
28.
29.
print
"\n"
;
30.
31.
32.
33.
while
(
$row
=
$result
->fetch_array( MYSQLI_BOTH ) ) {
34.
35.
for
(
$i
= 0;
$i
<
count
(
$field
);
$i
++ ) {
36.
37.
print
$row
[
$i
] .
" "
;
38.
39.
}
40.
41.
print
"\n"
;
42.
43.
44.
45.
}
46.
print
"</pre>"
;
47.
48.
}
49.
50.
51.
52.
53.
$mysqli
->close();
54.
55.
?>