Here I'll show you an simple example how to build your first report.
First we write the PHP script
<?php // The required inclusion require_once('sptpl.php'); require_once('sptpl.inc'); require_once('sptpl_db.php'); // The class istance $t=new sptpl(); // Load and parse the template file $t->LoadTemplate('test1.xml'); // Set some fields that will be used $t->SetVar("name","George"); $bar['foo']='Index foo'; $t->SetVar("bar",$bar); // Build the spool file $t->run("test1.txt"); ?> |
Second step, write the configuration file test1.xml
<?xml version='1.0' ?> <!-- The opening tag --> <template> <!-- Start the report definition --> <report> <!-- Set some text to print as the first row for this report --> <beginreport>Hi My First Test </beginreport> <!-- Set the body if our test, one row with Hello world. Notice, the field $name was declared from the PHP script --> <row id='pippo'> Hello world, my name is {$name} </row> <!-- And ending the report--> <closereport> End!That's all folk! </closereport> </report> </template> |