A script to generate a report from a valid mysql connection. The user has to supply which fields he wants to display in table. All properties are changable.
Class Name : phpReportGenerator
Version : 1.0
Written By : Hasin Hayder
Start Date : 4th July, 2004
Copyright : Systech Digital.
<?php
class phpReportGenerator
{
var $mysql_resource;
var $header;
var $foolter;
var $fields = array();
var $cellpad;
var $cellspace;
var $border;
var $width;
var $modified_width;
var $header_color;
var $header_textcolor;
var $header_alignment;
var $body_color;
var $body_textcolor;
var $body_alignment;
var $surrounded;
var $font_name;
//Check If our table has to be surrounded by an additional table
//which increase style of this table
if ($this->surrounded == true)
echo "<table width='$this->width' border='1' cellspacing='0' cellpadding='0'><tr><td>";
//Header Draw
for ($i = 0; $i< $field_count; $i++)
{
//Now Draw Headers
echo "<th align = '$this->header_alignment'><font color = '$this->header_textcolor' face = '$this->font_name'> ".$this->fields[$i]."</font></th>";
}
echo "</tr>";
//Now fill the table with data
while ($rows = mysql_fetch_row($this->mysql_resource))
{
echo "<tr align = '$this->body_alignment' bgcolor = '$this->body_color'>";
for ($i = 0; $i < $field_count; $i++)
{
//Now Draw Data
echo "<td><font color = '$this->body_textcolor' face = '$this->font_name'> ".$rows[$i]."</font></td>";
}
echo "</tr>";
}
echo "</table>";
if ($this->surrounded == true)
echo "</td></tr></table>";
}
}
?>
mysql_connect("localhost","root","root");
mysql_select_db("company");
$res = mysql_query("select name, age, area from table1 where age>20");
$prg->mysql_resource = $res;