I have the script below which generates PDF files. It all works fine but the problem I am having is with the array. If I put the $data = array( before the while statement then it will not put all of the items from the database into the PDF file. However of course if I put it inside like it is at the moment it will only put the last row into the PDF file. Does anyone know of a way of either doing this a little bit differently or how to get the array to work properly.
Thanks,
Matt
mysql_select_db($database_database, $database);
$sql = "SELECT * FROM billing";
$result = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($result) > 0) {
include ('pdf/class.ezpdf.php');
$pdf =& new Cezpdf();
$pdf->selectFont('pdf/fonts/Helvetica.afm');
$pdf->ezText('****** Invoice - 1st April 2005',20);
$pdf->ezSetDy(-10);
while ($row = mysql_fetch_array($result))
{
$data = array(
array('Item'=>$row[item],'Description'=>$row[description],'Price'=>$row[price])
,array('Item'=>$row[item],'Description'=>$row[description],'Price'=>$row[price])
);
}
$pdf->ezTable($data,$cols,'',
array('xPos'=>40,'xOrientation'=>'right','width'=>520
,'cols'=>array(
'Price'=>array('width'=>50,'justification'=>'left')
,'Item'=>array('width'=>30,'justification'=>'center'))
));
$pdf->ezStream();
}