I need our users to print a 2 page form letter (which will contain variables from our
database), I would like them to hit a button and send it directly to their printer or have them save it as a word document and print it.
I have found a php module in our system which sends output to an Ecxel spreadsheet, but for the life of me cannot figure out how it does this, it is the 3rd module in a group, the 1st asks the user for filtering and selection criteria, the 2nd obtains the data and this module sends it to an excel or back to the screen.
I have included the php code.
Any help or suggestions would be greatly appreciated:
The people who wrote all this are long gone, and I"m learning via W. Jason Gilmore's book Beginning PHP and MySQL 5.
Using PHP 5.1.6 Apache 1.3.37 MySQL 5.0.26
<?php
ini_set('max_execution_time','1200');
require_once 'faculty.php';
require_once 'querybuilder.php';
require_once 'logic.inc';
dbConnect();
$my_query = new QueryBuilder;
$my_query->setCriteriaArray($HTTP_POST_VARS[criteria_array]);
$my_query->setDisplayArray($HTTP_POST_VARS[display]);
$my_query->cleanCriteriaArray();
$my_query->runQuery();
if($HTTP_POST_VARS[save_query] == 1)
{
if($HTTP_POST_VARS[query_no] == 0)
{
$my_query->setName($HTTP_POST_VARS[save_as_name]);
$my_query->writeDb();
}
else
{
$my_query->setId($HTTP_POST_VARS[query_no]);
$my_query->updateDb();
}
}
$ticker = 0;
$temp = $HTTP_POST_VARS['criteria_array'];
$output_style = $temp[output_style];
unset($temp);
switch($output_style)
{
case "tabdelimited":
$i = 0;
$my_query->buildFacultyObjectArray();
if($crackmonkey == 1)
{
header("Content-type: text/plain");
}
else
{
header("Content-type: text/tab-separated-values");
}
foreach($HTTP_POST_VARS[display] as $value)
{
print $value . "\t";
}
print "\n";
foreach($my_query->getFacultyObjectArray() as $tso)
{
foreach($HTTP_POST_VARS[display] as $key=>$value)
{
print $tso->$key() . "\t";
}
print "\n";
}
break;
case "table":
printHead("Query Results");
$my_query->buildFacultyObjectArray();
startTable($HTTP_POST_VARS[display]);
$ticker = 0;
foreach($my_query->getFacultyObjectArray() as $tso)
{
foreach($HTTP_POST_VARS[display] as $key=>$value)
{
$print_array[] = $tso->$key();
}
printRow($print_array);
$ticker++;
unset($print_array);
}
finishTable();
print "<P>$ticker Results";
break;
}
?>