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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.