我是fpdf的新手,并且无法通过以下代码弄清楚我做错了什么。
我需要每页打印两条记录。
第一页生成正常,但没有生成其他页面。
可能是我的循环中有一个错误...请帮忙
当我给出像$ pic [$ i]这样的变量时,不打印alo图片,但是当我输入绝对路径是pictures / 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);
}
?>