<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <div> <form action="QuickSQL.php" method="get" name="sql"> <input name="sqlquery" type="text" value="<?php if (isset($_GET["sqlquery"])) echo htmlentities($_GET["sqlquery"]); ?>" style="width:100%;" /> <input name="" type="submit" /> </form> </div> <?php $Database = "DATABASE"; $DBhost = "HOST"; $DBlogin = "LOGIN"; $DBpassword = "SENHA"; $link=mysql_connect($DBhost, $DBlogin, $DBpassword) or die("Não pude conectar"); mysql_query("use $Database"); if (isset($_GET["sqlquery"])) { $sql = $_GET["sqlquery"]; $query=mysql_query($sql) or die(mysql_error()."Erro 01"); $linhas=mysql_num_rows($query); $count = 0; if ($linhas == 0) { echo "não há resultados!!!"; } else { echo "<table>\r\n"; while ($line = mysql_fetch_array($query, MYSQL_ASSOC)) { $count++; echo "<tr>\r\n"; if ($count == 1) { echo "<tr>\r\n"; foreach ($line as $key => $val) { echo "<td>\r\n"; echo htmlentities($key); echo "</td>\r\n"; } echo "</tr>\r\n"; } foreach ($line as $val) { echo "<td>\r\n"; echo htmlentities($val); echo "</td>\r\n"; } echo "</tr>\r\n"; } echo "</table>\r\n"; echo "<p>".mysql_num_rows($query)." rows in set</p>"; } } ?> </body> </html>