PHP で MySQL のクエリテストする為のコード( Bootstrap 仕様 )

$_GET['text'] で入力された SQL が引き渡されます。
※ GET コマンドなので、IE11 以外ならば SQLは アドレスバーで直接入力ができると思います。
※ php-mysql-test.php?text=SQL文

テーブルの表現には Bootstrap を使用しています( 一応スマホではテーブル部分のみ横スクロールします )

QueryString に text が無い場合と text に有効な文字が全く無い場合は  show variables でシステム変数の一覧を表示します
<?php
// キャッシュを使用しない
session_cache_limiter('nocache');
session_start();

// UTF-8
header( "Content-Type: text/html; charset=utf-8" );

?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta content="width=device-width initial-scale=1.0 minimum-scale=1.0 maximum-scale=1.0 user-scalable=no" name="viewport">
<title>SQL実行結果</title> 
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.css" />
<style>
/*
罫線等のテーブルのレイアウトは、Bootstrap にて適用
table {
	border: solid 1px #000;
	border-collapse: collapse;
}

th,td {
	border: solid 1px #000;
	padding: 5px;
}
*/
</style>
</head>
<body>
<!-- Bootstrap の alert でタイトル -->
<div class="alert alert-dark">
	MySQL Query TEST
</div>

<?php
if ( !isset( $_GET['text'] ) || trim($_GET['text']) == "" ) {
	// クエリ初期値は システム変数一覧
	$_GET['text'] = "show variables";
}

// P で挟んだデータの出力
print_cell_html( "p", $_GET['text'] );

$server = 'localhost';
$dbname = 'lightbox';
$user = 'root';
$password = 'パスワード';

// ***************************
// 接続
// ***************************
$mysqli = @ new mysqli($server, $user, $password, $dbname);
if ($mysqli->connect_error) {
	print "接続エラーです : ({$mysqli->connect_errno}) ({$mysqli->connect_error})";
	exit();
}

// ***************************
// クライアントの文字セット
// ***************************
$mysqli->set_charset("utf8"); 

// ***************************
// クエリ
// ***************************
$result = $mysqli->query($_GET['text']);
if ( !$result ) {
	print "\n";
	print "<span style='color:#f00'>error : " . $mysqli->error . "</span>";
	exit();
}

// ***************************
// 列数
// ***************************
$nfield = $result->field_count;
if ( $nfield ) {
	$ncount = 0;
	print "<div class='table-responsive-sm'>";
	print "<table class='table table-bordered table-hover'><thead class='thead-dark'>\n";

	// 行番号用タイトル
	print "\t<th></th>";

	// 列のタイトルを作成
	$field = $result->fetch_fields( );
	for( $i = 0; $i < $nfield; $i++ ) {

		// TH で挟んだデータの出力
		print_cell_html( "th", $field[$i]->name );

	}

	print "</thead>\n<tbody>\n";

	// ***************************
	// 行データ
	// ※ 結果の行を数値添字配列で取得
	// ***************************
	while ($row = $result->fetch_row()) {

		print "<tr>\n\t";
		// 行番号

		// TDで挟んだデータの出力
		print_cell_html( "td", ($ncount + 1) );

		for( $i = 0; $i < $nfield; $i++ ) {

			// TDで挟んだデータの出力
			print_cell_html( "td", $row[$i] );

		}
		print "\n</tr>\n";

		// 行番号
		$ncount++;
	}

	print "</tbody></table>";
	print "</div>";

}

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


// ***************************
// セルの HTML 出力関数
// ***************************
function print_cell_html( $html, $data ) {

print <<<CELL_HTML
<{$html}>{$data}</{$html}>
CELL_HTML;

}

?>

</body>
</html>