<?php

function select($result, $limit = 0) {
	for ($i=0; (!$limit || $i < $limit) && ($row = $result->fetch_row()); $i++) {
		if (!$i) {
			echo "<div class='scrollable'><table cellspacing='0' class='nowrap'><thead>";
			for ($j=0; $j < count($row); $j++) {
				$field = $result->fetch_field();
				$name = $field->name;
				$orgtable = $field->orgtable;
				$orgname = $field->orgname;
				echo "<th" . ($orgtable != "" || $field->name != $orgname ? " title='" . ($orgtable != "" ? "$orgtable." : "") . $orgname . "'" : "") . ">" . $name . '';				
			}
			echo "</thead>";
		}

		echo "<tr>";
		foreach ($row as $key => $val) {
			echo "<td>";
			echo $val;
			echo "</td>";
		}
		echo "</tr>";
	}
	echo ($i ? "</table></div>" : "");
}

//============================================================================

class MyDB extends MySQLi {
	var $extension = "MySQLi";

	function __construct() {
		parent::init();
	}

	function connect($server = "", $username = "", $password = "", $database = null, $port = null, $socket = null) {
		$return = @$this->real_connect($server, $username, $password, $database, $port);
		$this->options(MYSQLI_OPT_LOCAL_INFILE, false);
		return $return;
	}

}

$c = new MyDB();
$c->connect($_POST['server'], $_POST['username'], $_POST['password'], $_POST['db'], 3306);
$c->multi_query("select 1; select 2;");

do {
	$result = $c->store_result();
	if (is_object($result)) {
		select($result);
	}
} while ($c->next_result());

?>