IPT home IPT A Virtual Approach by Peter Whitehouse
Quick Links:
 
 
PHP home
Information and Intelligent Systems Social and Ethical Implications Human Computer Interaction Software and Systems Engineering eXercise Files Course Outline and Assessment A-Z of Geeky Acronyms Terrace Work Program 2004 Sillybus FAQ = Frequently Asked Questions Help
 
 

The Q Engine

Music/FirstFleet Database Portal


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 this:

 <?php    
 // [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($_POST[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
?>

The original idea for this query engine was kindly suggested by Mr Quentin Cregan ('Q') - thanks mate! Realised by -w-

 

wonko@wonko.info
©Copyright t 1992..2018+. Edition 26.150117
wonkosite
Creative Commons License
This work is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 2.1 Australia License
.