Jump to content

PHP Print PDF Report While Loop Problem


fabzster

Recommended Posts

Hi

 

I have a db that has the following Data for example:

 

PolicyNumber, StoreId, ConsultantName,ClientName, ClientSurname

 

I would like to have a report that will give me a list of policies done for that day seperated by store printed to PDF.

 

So Basically

 

Store - 12CEL

24Hr001 Bob Joe Soap

24Hr002 Bill Gill Henry

 

Store - 1156

24Hr003 Luke Manfred Kiy

24Hr004 Peter Ursula Jent

 

I currently use R&OS for pdf Printing

http://www.ros.co.nz/pdf

 

The Code below Gives me all policies, I just need to now seperate them in the PDF

//include pdf class
include ('class.ezpdf.php');

//Include PHP Mailer Class
require("class.phpmailer.php");

//Connect to database
mysql_connect("localhost", "root", "");
@mysql_select_db("mobility") or die("Unable to select database");

$queryP= mysql_query("SELECT * FROM tblpolicies WHERE CaptureDate='2006-04-03' ORDER BY StoreId");

$pdf =& new Cezpdf();
//$pdf->addJpegFromFile('policy.jpg',60,$pdf->y-750,500,0);
$pdf->selectFont('./fonts/Helvetica.afm');

$p = 750;


While($x=mysql_fetch_array($queryP)){ 

$pdf->addText(50,$p,7,"{$x['PolicyNumber']}");
$pdf->addText(80,$p,7,"{$x['StoreId']}");
$pdf->addText(120,$p,7,"{$x['NickName']}");
$pdf->addText(220,$p,7,"{$x['ClientsName']}");
$pdf->addText(330,$p,7,"{$x['DateReceived']}");
$pdf->addText(410,$p,7,"{$x['Comments']}");
$p = $p - 10;

if($p == 10){
    $pdf->ezNewPage();
    $p = 750;
    }



}

$pdf->ezText("\n\n\n\n\n\n\n" . $body,16,array('justification'=>'centre'));
$pdf->output();
$pdf->ezStream();

//write pdf stream to pdf file 
$pdfcode = $pdf->ezOutput();
$fp=fopen('policy.pdf','wb');
fwrite($fp,$pdfcode);
fclose($fp);

Link to comment
https://forums.phpfreaks.com/topic/224628-php-print-pdf-report-while-loop-problem/
Share on other sites

http://www.ros.co.nz/pdf

 

that looks like some ooooooooold and unsupported code, obviously using old versions of PDF. version 0.09 from 2006?? I suggest that you consider upgrading to FPDF/FPDI:

 

http://www.setasign.de/products/pdf-php-solutions/fpdi/

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.