親フォルダ
</pre>


<?php
require_once("db_connect.php");

if ( $_POST["query"] != "" ) {

	// SQL の実行
	$result = $mysqli->query( $_POST["query"] );
	if ( $result !== FALSE ) {

		// 列の情報一覧を取得
		$field = @$result->fetch_fields( );

		$a = "";

		$a .= "<tr>";
		for( $i = 0; $i < count( $field ); $i++ ) {

			$a .= "<td>{$field[$i]->name}</td>";

		}
		$a .= "</tr>";


		// 行データ変数の初期化
		$b = "";

		// MYSQLI_BOTH
		while ( $row = $result->fetch_array( MYSQLI_BOTH ) ) {

			$b .= "<tr>";
			for( $i = 0; $i < count( $field ); $i++ ) {

				$b .= "<td>{$row[$i]}</td>";

			}
			$b .= "</tr>";

		}

	}
	else {
		// エラー内容を保存
		$c = $mysqli->error;
	}

}

// ***************************
// 接続解除
// ***************************
$mysqli->close();

?>

<div style="padding: 0px 0px 0px 30px;margin-top:-40px">
<form method="post">
	<textarea name="query" style="width:800px;height:250px;"><?= $_POST["query"] ?></textarea>
	<br><input type="submit" name="send" value="送信">
</form>

<b style="color:red"><?= $c ?></b>

<table class="table table-hover table-responsive" style="margin-top:20px;">
	<?= $a ?>
	<?= $b ?>
</table>

</div>