我是 fpdf 的新手,无法弄清楚我在以下代码中做错了什么。
我需要每页打印两条记录。
第一页生成正常,但没有生成其他页面。
可能是我的循环中有错误...请帮助
当我给出 $pic[$i] 之类的变量时,alo 图片不会被打印,但是当我输入绝对路径(图片/1.jpg)时,它们会被打印。虽然图片正在使用 $pic[$i] 打印在其他文档中。
<?php
session_start();
if(isset($_SESSION['user']))
{
$cr = $_POST['cour'];
$s = $_POST['sem'];
$title = $cr." ".$s." ".'2012-13';
require('fpdf.php');
include('../includes/connection.php');
$sql = "SELECT * FROM `student` WHERE AppliedCourse ='$cr'";
$rs = mysql_query($sql) or die($sql. "<br/>".mysql_error());
if(0 == mysql_num_rows($rs))
{
$_SESSION['db_error'] = "<h2><font color = 'RED'>No such course found! Pease select again.</font></h2>";
header('Location: printAC.php');
}
else {
while($row = mysql_fetch_array($rs))
{
$formno[] = $row ['FormNo'];
$rno[] = $row ['rollno'];
$snm[] = $row ['StudentNm'];
$fnm[] = $row ['FathersNm'];
$mnm[] = $row ['MothersNm'];
$addr[] = $row['Address'];
$pic[] = $row['imagenm'];
$comm[] = $row['SocialCat'];
}
$pdf = new FPDF('P','pt','A4');
$pdf->SetFont('Times','B',16);
$pdf->SetMargins(44.737,90.20,44.737);
$pdf->SetAutoPageBreak('true',95);
$i = 0;
while($i < count($row))
{
$j = $i + 1;
$pdf->AddPage();
// Block 1
$pdf->SetFont('Times','B',16);
$pdf->SetXY(186.70,50.20);
$pdf->Cell(204.16,30,$title,0,0,'C');
// Block 1
$pdf->Image('pictures/1.jpg',475.34,30.20,64.5,79);
$pdf->Cell(165,260,' ',0,1,'');
// Block 1
$pdf->SetXY(55,80);
$pdf->SetFont('Helvetica','',14);
$pdf->Cell(60,20,'Roll No. : ',0,0,'L');
$pdf->Cell(60,20,$rno[$i],0,0,'L');
$pdf->Cell(70,20,'Form No. : ',0,0,'L');
$pdf->Cell(60,20,$formno[$i],0,0,'L');
$pdf->Cell(80,20,'Community : ',0,0,'L');
$pdf->Cell(60,20,$comm[$i],0,1,'L');
// Block 1
$pdf->SetXY(55,95);
$pdf->Cell(55,20,'Name :',0,0,'L');
$pdf->Cell(412,20,$snm[$i],0,1,'L');
// Block 1
$pdf->SetXY(55,115);
$pdf->Cell(170,12,"Father's/Husband's Name :",0,0,'L');
$pdf->Cell(323,12,$fnm[$i],0,1,'L');
// Block 1
$pdf->SetXY(55,130);
$pdf->Cell(105,12,"Mother's Name :",0,0,'L');
$pdf->Cell(372,12,$mnm[$i],0,1,'L');
// Block 1
$pdf->SetXY(55,145);
$pdf->Cell(60,12,"Address :",0,0,'L');
$pdf->Cell(165,60,$addr[$i],0,0,'');
//****************************************//
// Block 2
$pdf->SetFont('Times','B',16);
$pdf->SetXY(186.70,450.20);
$pdf->Cell(204.16,30,$title,0,0,'C');
// Block 2
$pdf->Image('pictures/2.jpg',475.34,430.20,64.5,79);
$pdf->Cell(165,260,' ',0,1,'');
// Block 2
$pdf->SetXY(55,480);
$pdf->SetFont('Helvetica','',14);
$pdf->Cell(60,20,'Roll No. : ',0,0,'L');
$pdf->Cell(60,20,$rno[$j],0,0,'L');
$pdf->Cell(70,20,'Form No. : ',0,0,'L');
$pdf->Cell(60,20,$formno[$j],0,0,'L');
$pdf->Cell(80,20,'Community : ',0,0,'L');
$pdf->Cell(60,20,$comm[$j],0,1,'L');
// Block 2
$pdf->SetXY(55,493);
$pdf->Cell(55,20,'Name :',0,0,'L');
$pdf->Cell(412,20,$snm[$j],0,1,'L');
// Block 2
$pdf->SetXY(55,510);
$pdf->Cell(170,12,"Father's/Husband's Name :",0,0,'L');
$pdf->Cell(323,12,$fnm[$j],0,1,'L');
// Block 2
$pdf->SetXY(55,525);
$pdf->Cell(105,12,"Mother's Name :",0,0,'L');
$pdf->Cell(372,12,$mnm[$j],0,1,'L');
// Block 2
$pdf->SetXY(55,540);
$pdf->Cell(60,12,"Address :",0,0,'L');
$pdf->Cell(165,60,$addr[$j],0,0,'');
$i++;
}
$pdf->Output();
}
mysql_close($con);
}
?>