PHP Classes
elePHPant
Icontem

File: usage.php

Recommend this page to a friend!
  Classes of Rupom Razzaque  >  SQL 2 PDF Report  >  usage.php  >  Download  
File: usage.php
Role: Example script
Content type: text/plain
Description: Example Usage
Class: SQL 2 PDF Report
Generate PDF documents from MySQL query results
Author: By
Last change: Because of some users' queries, I am adding a "PDF version" option. using this option, you will be able to set and get your preferred PDF version(according to your PDF reader).
Date: 10 years ago
Size: 2,001 bytes
 

Contents

Class file image Download
<?php
/**
* SQL2PDFReport Generator Class
*
* @author : MA Razzaque Rupom <rupom_315@yahoo.com>, <rupom.bd@gmail.com>
* Moderator, phpResource Group(http://groups.yahoo.com/group/phpresource/)
* URL: http://www.rupom.info
* @version : 1.0
* @date 06/05/2006 (modified on 06/23/2006)
* Purpose : Generating Pdf Report from SQL Query
*/

require_once('Sql2PdfReport.class.php');

//make sure the DB connection is ok
mysql_connect('localhost','root','');
mysql_select_db('test');

//queries whose output will be used as report data
$query_1 = "SELECT * FROM book";
$query_2 = "SELECT title,author FROM book";
$query_3 = "SELECT book_id,publisher,reader FROM book";

$obj = new Sql2PdfReport();

//sets absolute path where temporary report HTML file will be saved (should be under doc_root so that its URL can be set)
$obj->setHtmlPath("/projects/rupom/phpclasses/sql2pdfreport/first_test.html"); //change this according to your Path

//sets URL of the temporary report HTML file
$obj->setHtmlUrl("http://localhost/phpclasses/sql2pdfreport/first_test.html");//change this according to your URL

//inits row colors. colors will be repeated automatically
$obj->initRowColors(array('#336699','#f5f5f5'));

//generates report from $query_1
$obj->generateReport($query_1);

//changes row colors for the second report.
$obj->initRowColors(array('#f8f8f8','#336699','#353535'));

//generates report from $query_2 and appends it to previous report data
$obj->generateReport($query_2);

//generates report from $query_3 and appends it to previous report data
$obj->generateReport($query_3);

//pdf version
$pdfVersion = '1.4'; //change it according to your need
/*
$pdfVersion = 1.3 for Acrobat Reader 4
$pdfVersion = 1.4 for Acrobat Reader 5
$pdfVersion = 1.5 for Acrobat Reader 6
*/

//sets PDF version
$obj->setPdfVersion($pdfVersion);

//gets the pdf report of all the report data
$obj->getPdfReport();
?>