| Server IP : 61.19.30.66 / Your IP : 216.73.216.59 Web Server : Apache/2.2.22 (Ubuntu) System : Linux klw 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64 User : www-data ( 33) PHP Version : 5.3.10-1ubuntu3.48 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /var/www/gpa/sport/ |
Upload File : |
<?php
require('fpdf.php');
define('FPDF_FONTPATH','font/');
class PDF extends FPDF
{
//Load data
//Better table
function ImprovedTable($header,$data)
{
//Column widths
$w=array(1,3);
//Header
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C');
$this->Ln();
//Data
foreach ($data as $eachResult)
{
$this->Cell(0,100,$eachResult["Name"],1,0,'C');
$this->MultiCell(0,100,$eachResult["Username"],1,0,'C');
$this->Ln();
}
//Closure line
$this->Cell(array_sum($w),0,'','T');
}
//Colored table
function FancyTable($header,$data)
{
//Data
$fill=false;
foreach($data as $row)
{
$this->Cell($w[10],1,$row[0],'LR',0,'L',$fill);
$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
$this->Cell($w[2],6,$row[2],'LR',0,'L',$fill);
$this->Ln();
$fill=!$fill;
}
$this->Cell(array_sum($w),0,'','T');
}
}
$pdf=new PDF('L' , 'mm' , 'A4');
//Column titles
//$header=array('รหัส','สินค้า','จำนวนเบิก','ชื่อ','นามสกุล','รหัสสินค้า','วันที่เบิก');
//Data loading
//*** Load MySQL Data ***//
$objConnect = mysql_connect("localhost","root","klw3322") or die("Error Connect to Database");
$objDB = mysql_select_db("klw");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_results=tis620");
mysql_query("SET character_set_client=tis620");
mysql_query("SET character_set_connection=tis620");
$strSQL = "SELECT * FROM klw where cllass=1 and room=1";
$objQuery = mysql_query($strSQL);
$resultData = array();
for ($i=0;$i<mysql_num_rows($objQuery);$i++) {
$result = mysql_fetch_array($objQuery);
array_push($resultData,$result);
}
//************************//
$pdf->AddFont('angsa','','angsa.php');
$pdf->SetFont('angsa','',30);
//*** Table 1 ***//
$pdf->AddPage();
//$pdf->Image('logo.png',80,8,33);
//$pdf->Ln(35);
//$pdf->BasicTable($header,$resultData);
//*** Table 2 ***//
$pdf->AddPage();
//$pdf=new PDF('P' , 'mm' , 'A4');
//$pdf->Image('logo.png',80,8,33);
$pdf->Ln(35);
$pdf->ImprovedTable($header,$resultData);
//*** Table 3 ***//
//$pdf->AddPage();
//$pdf->Image('logo.png',80,8,33);
//$pdf->Ln(35);
//$pdf->FancyTable($header,$resultData);
$pdf->Output("MyPDF/MyPDF.pdf","F");
?>
PDF Created Click <a href="MyPDF/MyPDF.pdf">here</a> to Download
</body>
</html>