<?php
// test the table functions
error_reporting(E_ALL);
include('ros/class.ezpdf.php');
$pdf =& new Cezpdf();
$pdf->selectFont('ros/fonts/Helvetica');
$fname = 'ros_people.pdf';
//--------------------------------------------------
// connect to your db
// database connection - removed for presentation
//--------------------------------------------------
// open the connection to the db server
$link = mysql_connect($host,$user,$password);
// change to the right database
mysql_select_db($database);
// initialize the array
$data = array();
$query = 'select * from people';
$result = mysql_query($query);
// step through the result set, populating the array, note that this could also have been written:
// while($data[] = mysql_fetch_assoc($result)) {}
while($data[] = mysql_fetch_array($result, MYSQL_ASSOC)) {}
// make the table
$pdf->ezTable($data);
// do the output, this is my standard testing output code, adding ?d=1
// to the url puts the pdf code to the screen in raw form, good for checking
// for parse errors before you actually try to generate the pdf file.
if (isset($d) && $d){
$pdfcode = $pdf->output(1);
$pdfcode = str_replace("\n","\n<br>",htmlspecialchars($pdfcode));
echo '<html><body>';
echo trim($pdfcode);
echo '</body></html>';
} else {
$pdf->stream();
}
$pdfcode = $pdf->output();
$fp = fopen($fname,'w');
fwrite($fp,$pdfcode);
fclose($fp);
?>