<html>
<head>
<title>Test SQL Code via PHP</title>
</head>
<body style='background-color:pink;'>
<?php
 $ourhost="localhost:8889";
 $ouruser="root";
 $ourpassword="root";
 mysql_connect($ourhost, $ouruser, $ourpassword);
 mysql_select_db($_POST['db']);
 $res = stripSlashes($_POST['qy']);
 $res = mysql_query($_POST['qy']);
?>

Query results <b><?php echo($_POST['qy']); ?></b><hr>

<?php
if ($res == 0):
  echo("<b>Error " . mysql_errno() . ": " . mysql_error() . "</b>");
elseif (mysql_num_rows($res) == 0):
  echo("<b>Query executed successfully</b>");
else:
?>
<table border=1>
<thead>
<tr>
<?php
for ($ii = 0; $ii < mysql_num_fields($res); $ii++) {
 echo("<th>" . mysql_field_name($res,$ii) . "</th>");
}
?>
</tr>
</thead>
<tbody>
<?php
for ($ii = 0; $ii < mysql_num_rows($res); $ii++) {
 echo("<tr>");
 $r_array = mysql_fetch_row($res);
 for ($jj = 0; $jj < mysql_num_fields($res); $jj++) {
 echo("<td>" . $r_array[$jj] . "</td>");
 }
 echo("</tr>");
}
?>
</tbody>
</table>
<?php
endif
//mysql_close();
?>
<hr><br>
</form
</body>
</html>

