我想使用下面的代码将此视图发送到pdf文件。我只下载了它并稍微编辑了一下。这个错误表明: 警告:mysql_fetch_array()期望参数1是资源,第77行的C:\ wamp64 \ www \ OFES \ Department.php中给出的对象。 FPDF错误:某些数据已经输出,无法发送PDF文件
我不知道代码是什么。请帮助我
<?php
require('fpdf/fpdf.php');
class PDF extends FPDF
{
//Page header
function Header()
{
$pdf = new PDF();
$pdf->Cell(55, 10, "Comment", 1, 0, "L", 1);
}
//Page footer
function Footer()
{
//Position at 1.5 cm from bottom
$this->SetY(-15);
//Arial italic 8
$this->SetFont('Arial','I',8);
//Page number
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
$pdf = new PDF();
$pdf->open();
$pdf->AddPage();
$pdf->AliasNbPages(); // necessary for x of y page numbers to appear in document
$pdf->SetAutoPageBreak(true);
// document properties
$pdf->SetAuthor('INSERT AUTHOR');
$pdf->SetTitle('INSERT DOC TITLE');
$pdf->SetFont('Arial','B',14);
$pdf->Cell(40,10,' TITLE FOR REPORT');
// Add date report ran
$pdf->SetFont('Arial','I',10);
$date = date("F j, Y");
$pdf->Cell(40,30,'Report date: '.$date);
$pdf->SetDrawColor(0, 0, 0); //black
//table header
$pdf->SetFillColor(170, 170, 170); //gray
$pdf->setFont("Arial","B","9");
$pdf->setXY(10, 40);
$pdf->Cell(40, 10, "Facutly Name", 1, 0, "L", 1); // CHANGE THESE TO REPRESENT YOUR FIELDS
$pdf->Cell(18, 10, "Department", 1, 0, "L", 1);
$pdf->Cell(25, 10, "Pr", 1, 0, "L", 1);
$pdf->Cell(30, 10, "AR", 1, 0, "L", 1);
$pdf->Cell(55, 10, "IR", 1, 0, "L", 1);
$pdf->Cell(55, 10, "PET", 1, 0, "L", 1);
$pdf->Cell(55, 10, "CMO", 1, 0, "L", 1);
$pdf->Cell(55, 10, "OI", 1, 0, "L", 1);
$pdf->Cell(55, 10, "II", 1, 0, "L", 1);
$pdf->Cell(55, 10, "MSP", 1, 0, "L", 1);
$pdf->Cell(55, 10, "Overall", 1, 0, "L", 1);
$y = 50;
$x = 10;
$pdf->setXY($x, $y);
$pdf->setFont("Arial","","9");
require('getindividualreports.php');
$sql = "SELECT * FROM tbl_formative_department_final";
$result = mysqli_query($con,$sql) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$pdf->Cell(40, 8, $row['faculty_name'], 1);
$pdf->Cell(18, 8, $row['Department'], 1);
$pdf->Cell(25, 8, $row['PR'], 1);
$pdf->Cell(30, 8, $row['AR'], 1);
$pdf->Cell(55, 8, $row['IR'], 1);
$pdf->Cell(55, 8, $row['PET'], 1);
$pdf->Cell(55, 8, $row['CMO'], 1);
$pdf->Cell(55, 8, $row['OI'], 1);
$pdf->Cell(55, 8, $row['II'], 1);
$pdf->Cell(55, 8, $row['MSP'], 1);
$pdf->Cell(55, 8, $row['Overall'], 1);
$y += 8;
if ($y > 260) // When you need a page break
{
$pdf->AddPage();
$y = 40;
}
$pdf->setXY($x, $y);
}
$pdf->Output();
?>
&#13;