I want to view this to pdf file using this code below. I only downloaded it and edit it a little. There's this error stated that: Warning: mysql_fetch_array() expects parameter 1 to be resource, object given in C:\wamp64\www\OFES\Department.php on line 77. FPDF error: Some data has already been output, can't send PDF file
I dont know what is the with the code.Please help me
<?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();
?>
.