Home
PHP
Application
Php Manual
Pictures
GuestBook
 
 
  Introduction Dlog Aprint SpTpl 
  Yap Xml2Array

 

 

 
 
 
Ex. index Quick Start Basic ex.
1st report Database Columns
Pdf output Pdf report Tag function
   

Quick start

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>
 

Copyright © 2003-2008 Darvin Andrioli, last change 06/09/2003