we get message :
unable to handle MIME type: text/html
when we view the saved pdf document.
we use fpdf, cakePHP, MySQL to output table to a pdf report. cakePHP
seems to insist on that mime type instead of application/pdf? we
don't understand what is causing this?
also, we think because our code is not cake-ified yet? code is
below. suggestions most welcome. still struggling with cakePHP but
beginning to like it.
thanks,
ige
test2.php
<?php
require('fpdf/fpdf.php');
$host = 'localhost'; // MYSQL database host adress
$db = 'ischoolsdev'; // MYSQL database name
$user = 'root'; // Mysql database user
$pass = 'ischoolsuser'; // Mysql database password
// Connect to the database
$link = mysql_connect($host, $user, $pass);
mysql_select_db($db);
class PDF extends FPDF
{
//Load data
function LoadData()
{
$query = "SELECT * from schools;";
$Result = mysql_query( $query );
$size=mysql_num_rows($Result);
for($i=0;$i<$size;$i++)
$row[$i] = mysql_fetch_row($Result);
mysql_free_result( $Result );
$data=array();
for($i=0;$i<$size;$i++)
{
$data[] = $row[$i];
}
return $data;
}
//Better table
function ImprovedTable($header,$data)
{
//Column widths
$w=array
(20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,15,15,15);
//Header
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],5,$header[$i],1,0,'C');
$this->Ln();
//Data
foreach($data as $row)
{
for($i=0;$i<sizeof($row);$i++)
$this->Cell($w[0],4,$row[$i],'LR');
//$this->Cell($w[1],6,$row[1],'LR');
//$this->Cell($w[2],6,number_format($row[2]),'LR',0,'R');
//$this->Cell($w[3],6,number_format($row[3]),'LR',0,'R');
$this->Ln();
}
//Closure line
$this->Cell(array_sum($w),0,'','T');
}
}
$pdf=new PDF();
//Column titles
$header=array
('Code','Rname','Xname','Zname','Ydesc','Wdesc','Udesc','Tdesc','Sdesc','Street','Brgy','line1','mobile','fax','gps
lat','gps long','Ydesc','head','designation','contact','designation');
//Data loading
$data=$pdf->LoadData();
$pdf->SetFont('Arial','',14);
$pdf->AddPage('L');
$pdf->ImprovedTable($header,$data);$pdf->AddPage('L');
$pdf->Output();
?>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---