<?php // ******************************************************************* // admin/modules/query_box.php // *******************************************************************
// ******************************************************************* // if info is requested display it, if your want to show the form as // well, just comment the "exit;" if ($_POST['info']) { echo "<br><blockquote> This is a quick way to execute MySQL queries directly from your admin panel. see : http://dev.mysql.com/doc/ <hr> <blockquote><br>"; //exit; } // was a query just exectuded ? $version = printf ("MySQL server version: %s\n", mysql_get_server_info());
if (!empty($_POST['submit'])) { $query = $_POST['query']; $query = stripslashes($query); echo "<p>". $query ."</p>";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
/* Printing results in HTML */ print '<table width="90%" bgcolor=#CFCFEF cellpadding=2 cellspacing=1>'; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { print "\t<tr>\n"; foreach ($line as $col_value) { print "\t\t<td bgcolor=#FFFFFF>$col_value</td>\n"; if ($query =="show tables;"){print "\t<form method=\"post\" action=\"./modules.php\">\n <td bgcolor=#FFFFFF>\n <input type=hidden name=module value=query_box.php>\n <input type=hidden name=query value=\"describe ". $col_value .";\">\n <input class=\"button\" type=\"submit\" name=\"submit\" value=\"Describe\">\n </td></form>\n"; print "\t<form method=\"post\" action=\"./modules.php\">\n <td bgcolor=#FFFFFF>\n <input type=hidden name=module value=query_box.php>\n <input type=hidden name=query value=\"select * from ". $col_value .";\">\n <input class=\"button\" type=\"submit\" name=\"submit\" value=\"Browse\">\n </td></form>\n";
} } print "\t</tr>\n"; } print "</table>\n";
/* Free resultset */ mysql_free_result($result); } ?> <table border=1> <form method="post" action="./modules.php"> <tr><td>Enter query <a target=_blank href=http://dev.mysql.com/doc/><?></a> <br> <textarea rows=7 cols=60 name=query># enter your query below</textarea> <input type=hidden name=module value=query_box.php> <tr><td><input class="button" type="submit" name="submit" value="ENTER"></td> <tr></form><td> <form method="post" action="./modules.php"> <input type=hidden name=module value=query_box.php> <input type=hidden name=query value="show tables;"; <input class="button" type="submit" name="submit" value="Show Tables"> </td></tr> </tr></form></table>
|
|