親フォルダ
</pre>


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

if ( $_POST["send1"] != "" ) {
	$_POST["query"] = $_POST["query1"];
}
if ( $_POST["send2"] != "" ) {
	$_POST["query"] = $_POST["query2"];
}
if ( $_POST["send3"] != "" ) {
	$_POST["query"] = $_POST["query3"];
}

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" style="display:inline-block">
<div style="display:inline-block">
	<textarea name="query1" style="width:500px;height:250px;"><?= $_POST["query1"] ?></textarea>
	<br><input type="submit" name="send1" value="送信">
</div>
<div style="display:inline-block">
	<textarea name="query2" style="width:500px;height:250px;"><?= $_POST["query2"] ?></textarea>
	<br><input type="submit" name="send2" value="送信">
</div>
<div style="display:inline-block">
	<textarea name="query3" style="width:500px;height:250px;"><?= $_POST["query3"] ?></textarea>
	<br><input type="submit" name="send3" value="送信">
</div>
</form>

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

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

</div>