topical media & game development
server-php-db-browser-dbbrowser.php / php
<?php
/*------------------------------------------------------------------------------------------
DB Browser
ŠPhpToys 2006
http://www.phptoys.com
Released under the terms and conditions of the
GNU General Public License (http://gnu.org).
USAGE:
Just copy the file to your webserver and load it.
--------------------------------------------------------------------------------------------*/
session_start();
sqlerror = "";
if (isset(sitemode=_GET['db'])) { _GET['db']; dbname;}
if (isset(tablename=_SESSION['table']=sitemode == 0) && (!isset(_SERVER['PHP_SELF']; ?>" method="post" name="convertForm">
<table width="100%" >
<tr align=left>
<td class="text">Hostname:</td>
<td><input name="hostname" value="localhost" /></td>
</tr>
<tr align=left>
<td class="text">User name:</td>
<td><input name="username" value="" /></td>
</tr>
<tr align=left>
<td class="text">Password:</td>
<td><input name="password" type="password" value="" /></td>
</tr>
<tr>
<td style="text-align: center;" colspan="2"><br/><input type="submit" name="submitdb" value="Show databases" /></td>
</tr>
</table>
</form>
<?php } if ((_POST['submitdb']))){
_POST['hostname'];
_POST['username'];
_POST['password'];
hostname;
username;
password;
hostname, password);
if (!sitemode=1;
} if (result = mysql_query('SHOW databases');
if (!i=1;
while (result, MYSQL_NUM)) {
echo '<tr><td align="center">'._SERVER['PHP_SELF'].'?mode=2&db='.row[0].'</a></td></tr>';
result);
mysql_close(sitemode == 2) {
_SESSION['hostname'],_SESSION['password'] );
if (!_SESSION['dbname']);
result) die('Invalid query: ' . mysql_error());
echo '<table width="300"><tr><th width="100">Nr.</th><th>Tables in '.i=1;
while (result, MYSQL_NUM)) {
echo '<tr><td align="center">'._SERVER['PHP_SELF'].'?mode=3&table='.row[0].'</a></td></tr>';
result);
mysql_close(sitemode == 3) {
_SESSION['hostname'],_SESSION['password'] );
if (!_SESSION['dbname']);
_SESSION['table']);
if (!i=1;
while (result, MYSQL_ASSOC)) {
if (row as value) {
echo '<th class="th1"> '.row as value) {
if ( value=" ";
echo '<td class="td1"> '.i++;
}
if (result);
mysql_close(
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.