<?php
// test the table functions
error_reporting(E_ALL);
include('ros/class.ezpdf.php');
$pdf =& new Cezpdf();
$pdf->selectFont('ros/fonts/Helvetica');
$pdf->setLineStyle(5,'round');
$fname = 'ros_people_places.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);
$query = 'SELECT p.*, pe.first_name, pe.last_name, pl.name, pl.area_name FROM people_places p LEFT JOIN people pe ON ( p.people_id = pe.id ) LEFT JOIN places pl ON ( p.places_id = pl.id )';
$result = mysql_query($query);
$y = 780;
while ($row = mysql_fetch_assoc($result)) {
$pdf->line(30,$y+34,300,$y+35);
$pdf->addText(30,$y+20, 10, $row['first_name'].' '.$row['last_name'].' went to '.$row['name'].', '.$row['area_name']);
$y = $y-20;
}
$pdf->line(30,$y+34,300,$y+35);
// 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);
?>