Tuesday, 10 September 2013

PHP to PDF using FPDF failing to open my pdf file(broken)

PHP to PDF using FPDF failing to open my pdf file(broken)

just wanna ask if why is my pdf file is not opening in nitro pdf. Im using
fpdf. Im just trying to have a fancy table in my pd, but it seems that
there is an error. Anyone who can figure out which is it? here is the
code:
<?php
require_once("fpdf/fpdf.php");
class PDF extends FPDF
{
function FancyTable()
{
// Colors, line width and bold font
$this->SetFillColor(255,0,0);
$this->SetTextColor(255);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.3);
// Header
$w = array(40, 35, 40, 45);
$this->Cell($w[$i],7,$header["Name"],1,0,'C',true);
$this->Cell($w[$i],7,$header["ID Number"],1,0,'C',true);
$this->Cell($w[$i],7,$header["Passwords"],1,0,'C',true);
$this->Ln();
// Color and font restoration
$this->SetFillColor(224,235,255);
$this->SetTextColor(0);
$this->SetFont('');
// Data
$fill = false;
do {
$shanks = $row_getstudent['stud_valid_nos'];
$mugiwara = mysql_query("SELECT * FROM exam_sections WHERE sec_id_num
= '$shanks'")or die(mysql_error());
while($ben = mysql_fetch_array($mugiwara)){
$beckman = $ben['sec_firstname'];
$usopp = $ben['sec_lastname'];
}
$trafalgar = $row_getstudent['stud_id'];
$vergo = mysql_query("SELECT pass_password FROM exam_passwords WHERE
pass_user_id = '$trafalgar'")or die(mysql_error());
while($caesar = mysql_fetch_array($vergo)){
$smoker = $caesar['pass_password'];
}
$this->Cell($w[0],6,"$beckman $usopp",'LR',0,'L',$fill);
$this->Cell($w[2],6,"Shanks",'LR',0,'R',$fill);
$this->Cell($w[3],6,"$smoker",'LR',0,'R',$fill);
$this->Ln();
$fill = !$fill;
} while ($row_getstudent = mysql_fetch_assoc($getstudent));
// Closing line
$this->Cell(array_sum($w),0,'','T');
}
}
$pdf = new PDF();
$pdf->AddPage();
$pdf->FancyTable();
$pdf->Output();
$pdf->SetAutoPageBreak(true, 20);
$pdf->SetMargins(20, 20, 20);
$pdf->Cell(40,10,'PDF for '.$subj);
$pdf->Ln(10);
$pdf->Output();?>

No comments:

Post a Comment