The
Q Engine
Music
Database
The Code this form runs
looks like this:
<form action="blah.php" method="post">
<textarea name="query" rows="10" cols="80">select
</textarea>
<br>
<input type=submit value="Post My Query">
</form>
***
Where the PHP script in blah.php looks like:
***
<?php
/*
* Uberfast ultracraptastic mysql adhoc [q]uery engine
*/
$link = mysql_connect("localhost", "username", "password") or die("Unable to connect");
print "Connected successfully | <a href="q.php">BACK</a><p>";
mysql_select_db("dbname") or die("Unable to select database");
$query = stripslashes($HTTP_POST_VARS[query]);
$result = mysql_query($query);
$rows = mysql_num_rows($result);
print "There are $rows rows<p>";
$columns = mysql_num_fields($result);
print "Query: $query";
if ($rows > 0) {
print "<p> <table border=1><tr>";
for ($x = 0; $x < $columns; $x++) {
print "<th>";
$name = mysql_field_name($result,$x);
print "$name";
print "</th>";
}
print "</tr>";
while ($row = mysql_fetch_row($result)) {
print "<tr>";
for ($y =0; $y < $columns; $y++) {
print "<td>$row[$y]</td> ";
}
print "</tr>";
}//end while
print "</table>";
} //end if
?>
</body>
</html>
The original code
for this query engine was kindly written by Mr Quentin Cregan ('Q') - thanks
mate!
|