Jump to content

Recommended Posts

I want to display Student's Result as a PDF file.I have used fpdf library from
http://www.fpdf.org/

I have followed their scripts for HTML table (Author Azeem Abbas)

 

Here is my result link:

 

http://bhc.edu.in/commerce/Studresult.php?exno=12345

 

 

I want to align the tables' rows and columns.How can i?Please help.

My PDF file : (Studresult.php)

http://pastebin.com/LdTwc3ya

 

HTML Table by fpdf: (html_table.php)

 

http://pastebin.com/hc6xjPua

Thanks in advance

 

Link to comment
https://forums.phpfreaks.com/topic/282087-php-to-pdf-report/
Share on other sites

Hi. 



<?php

require('fpdf.php');

require('TOURDABASECONNECTION.PHP');


class PDF extends FPDF {



        function BuildTable($header,$data) {

   

        $this->SetFillColor(159,159,158);

        $this->SetTextColor(0);

        $this->SetDrawColor(0,0,0);

        $this->SetLineWidth(.1);

        $this->SetFont('','');

        $w=array(8,35,80,43,30,8,;

        for($i=0;$i<count($header);$i++)

        $this->Cell($w[$i],7,$header[$i],1,0,'C',1);

        $this->Ln();

        

        $this->SetFillColor(201,201,201);

        $this->SetTextColor(0);

        $this->SetFont('');

        $fill=true; 

        foreach($data as $row)

        {

		$this->Cell($w[0],6,$row[0],'LR',0,'C',$fill);

        $this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);

        $this->SetTextColor(0);

        $this->SetFont('');

        $this->Cell($w[2],6,$row[2],'LR',0,'L',$fill);
		$this->Cell($w[3],6,$row[3],'LR',0,'L',$fill);
		$this->Cell($w[4],6,$row[4],'LR',0,'L',$fill);
		$this->Cell($w[5],6,$row[5],'LR',0,'C',$fill);
		$this->Cell($w[6],6,$row[6],'LR',0,'C',$fill);

        $this->Ln();

        $fill =! $fill;

        }

        $this->Cell(array_sum($w),0,'','T');

        }

}
	$disquery = "Select * from results where Examno = '$exnum'"; $disuser = mysql_query($disquery)or die(mysql_error());

While($row = mysql_fetch_array($disuser))
	{	$data[] = array(
						$row['Subcode'], 
						$row['Title'], 
						$row['CIA'],
						$row['ESE'],
						$row['Credits'],
						$row['Grade'],
						$row['Gradept']);
						}

$pdf = new PDF('P','mm','A3');

$header=array('PAPER CODE','TITLE','CIA','ESE','CREDIT EARNED','GRADE','GRADE POINT');

$pdf->SetFont('Arial','',9);

$pdf->AddPage();

$pdf->BuildTable($header,$data);

$pdf->Output();
?>

Link to comment
https://forums.phpfreaks.com/topic/282087-php-to-pdf-report/#findComment-1449191
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.