Check out this code. There are 108 records
in the table and when the pdf file opens
up, the 26th person appears on the next page, but does anybody know how to get the twenty-five records on each page. Only one record ouputs on each page along with the headings.
Need help!!!
$targetfile = "pdftest.pdf";
$fp=fopen($targetfile,"w");
$pdf = pdf_open($fp);
$height = 8.572;
$width = 1172;
$headings = "Last Name";
$qry = "SELECT * \n";
$qry = $qry . "FROM $db_table \n";
$result = mysql_query($qry, $connect);
$length = mysql_num_rows($result);
$linenum = 0;
for($i=0; $i<$length; $i++) {
$linenum = $linenum + 1;
$name = mysql_result($result, $i, 'name');
$fileline = $name;
if ($i==0){
pdf_begin_page($pdf, $height, $width);
pdf_set_font($pdf, "Helvetica", 14, "host");
pdf_set_text_pos($pdf, 50, 700);
pdf_show($pdf, $headings);
pdf_continue_text($pdf, $fileline);
pdf_end_page($pdf);
}
if($linenum == 25) {
pdf_begin_page($pdf, $height, $width);
pdf_set_font($pdf, "Helvetica",4, "host");
pdf_set_text_pos($pdf, 50, 700);
pdf_show($pdf, $headings);
pdf_continue_text($pdf, $fileline);
pdf_end_page($pdf);
$linenum = 0;
}
}
?>
<?
mysql_close($connect);
pdf_close($pdf);
fclose($fp);
?>