PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of juan manuel   SQL Revealer   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: main
Class: SQL Revealer
Show data from a MySQL database as an HTML table
Author: By
Last change:
Date: 19 years ago
Size: 4,234 bytes
 

Contents

Class file image Download
<?php
/* ===================================================================== *\
# #
# +-----------------------------------------------------------+ #
# | Author: Juan Manuel Sueiro | #
# | Contact: <jmsueiro[at]gmail.com> | #
# | httpLink: <http://tziweblog.com.ar> | #
# | Desc: reveal data of mysql db | #
# +-----------------------------------------------------------+ #
# #
\* ===================================================================== */
require_once("SimpleConstructorClass.php");

/* ===================================================================== */
/* Put here the user data to access your database
/* ===================================================================== */
$cfg['dbUser'] = 'root';
$cfg['dbPass'] = '';
$cfg['dbHost'] = 'localhost';
$cfg['dbName'] = '';

/* ===================================================================== */
/* Table formating
/* ===================================================================== */
$cfg['CSSClass'] = 'tahoma11'; //CSS font class
$cfg['borderColorLight'] = '#336699';
$cfg['borderColorDark'] = '#000000';
$cfg['borderColor'] = '#336699';
$cfg['bgColor'] = '#336699';
$cfg['imgBackground'] = ''; //img filename and path
$cfg['align'] = 'center';
$cfg['width'] = 400;
$cfg['border'] = 1;
$cfg['cellspacing'] = 2;
$cfg['cellpadding'] = 4;

#----------------------------------------------------------------#
# [cfg]
#----------------------------------------------------------------#
$simpleSql = &New simpleConstructor;
$simpleSql->dbhost = $cfg['dbHost'];
$simpleSql->dbuser = $cfg['dbUser'];
$simpleSql->dbpass = $cfg['dbPass'];
$simpleSql->database = $cfg['dbName'];
$simpleSql->db_connect();

$arLink = array();
#----------------------------------------------------------------#
# [init]=> Begin Actions [prototype]
#----------------------------------------------------------------#
$result = mysql_list_tables($cfg['dbName']);
if(
$r = mysql_fetch_array($result)){
do{
       
$simpleSql->vclass = $cfg['CSSClass'];
       
$simpleSql->bordercolorlight = $cfg['borderColorLight'];
       
$simpleSql->bordercolordark = $cfg['borderColorDark'];
       
$simpleSql->bordercolor = $cfg['borderColor'];
       
$simpleSql->bgcolor = $cfg['bgColor'];
       
$simpleSql->background = $cfg['imgBackground'];
       
$simpleSql->align = $cfg['align'];
       
$simpleSql->width = $cfg['width'];
       
$simpleSql->border = $cfg['border'];
       
$simpleSql->cellspacing = $cfg['cellspacing'];
       
$simpleSql->cellpadding = $cfg['cellpadding'];
       
$simpleSql->sql = 'SELECT * from '.$r[0].' order by id desc';
       
           
array_push($arLink, '<a href="#'.$r[0].'">'.$r[0].'</a>');
       
       
$vTmp .= '<a name="'.$r[0].'"></a><span class="'.$cfg['CSSClass'].'">Data for table: '.$r[0].' | <a href="#init">top</a></span><br>';
       
$construct = $simpleSql->sqlExec();
            if(!empty(
$construct)){ $vTmp .= $construct; }else{ $vTmp .= "Constructor Return : ".mysql_error().'<br>'; };
       
$vTmp .= '<br><br>';

} while (
$r = @mysql_fetch_array($result));
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>sqlRevealer</title>
<style type="text/css">
<!--
.tahoma11 { font-family: tahoma; font-size: 11px; color: #003366; text-decoration:none; }
a:hover { font-family: tahoma; font-size: 11px; color: #336699; text-decoration:none; }
a:link { font-family: tahoma; font-size: 11px; color: #003366; text-decoration:none; }
a:visited { font-family: tahoma; font-size: 11px; color: #003366; text-decoration:none; }
-->
</style>
</head>
<body><a name="init"></a>
<span class="tahoma11">Table information for db <?php echo $cfg['dbName']?>:
<?php foreach($arLink as $lv){ echo $lv.' | '; };?>
</span><br>
<?php echo $vTmp; ?>
</body>
</html>