The basic sample

Its the smallest thing you can do with PHPReports, make a XML report file like this and name it sales.xml:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<REPORT>
   <TITLE>Sales Report</TITLE>
   <BACKGROUND_COLOR>#FFFFFF</BACKGROUND_COLOR>
   <PAGE SIZE="25"></PAGE>
   <GROUPS>
      <GROUP NAME="maingroup">
         <FIELDS>
            <ROW>
               <COL TYPE="FIELD">id</COL>
               <COL TYPE="FIELD">name</COL>
               <COL TYPE="FIELD">city</COL>
               <COL TYPE="FIELD">product</COL>
               <COL TYPE="FIELD">value</COL>
            </ROW>
         </FIELDS>
      </GROUP>
   </GROUPS>
</REPORT>
				
Now you need the PHP code to make it works. Put the following code inside a file called sales.php:
<?php
   // include the PHPReports classes on the PHP path! configure your path here
   ini_set("include_path",ini_get("include_path").":/var/www/html/phpreports/"); 
   include "PHPReportMaker.php";

   $sSQL = "select * from saleslog order by city,id";
   $oRpt = new PHPReportMaker();

   $oRpt->setXML("sales.xml");
   $oRpt->setUser("taq");
   $oRpt->setPassword("******");
   $oRpt->setConnection("localhost");
   $oRpt->setDatabaseInterface("mysql");
   $oRpt->setSQL($sSQL);
   $oRpt->setDatabase("phpreports");
   $oRpt->run();
?>
			
If everything is ok, Apache is running, Sablotron was correctly installed, when you point your browser
to sales.php you'll see something like this:

sales.xml result file

Argh! Ugly uh? Where's that cute report we saw on the previous section? Just hold on and we'll see it soon. :-)