|
 |
|
ใช้งานฟังก์ชั่นสร้าง table ใน FPDF ไม่ได้ครับ + สอบถามเกี่ยวกับการเรียกใช้งานฟังก์ชั่นอื่นๆใน FPDF ด้วยครับ |
|
 |
|
|
 |
 |
|
<?php
/*call the FPDF library*/
require('fpdf.php');
class PDF extends FPDF
{
//Load data
function LoadData($file)
{
//Read file lines
$lines = file($file);
$data = array();
foreach ($lines as $line)
$data[] = explode(';', chop($line));
return $data;
}
//Simple table
function BasicTable($header, $data)
{
//Header
$w = array(30, 30, 55, 25, 20, 20);
//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(30, 6, $eachResult["CustomerID"], 1);
$this->Cell(30, 6, $eachResult["Name"], 1);
$this->Cell(55, 6, $eachResult["Email"], 1);
$this->Cell(25, 6, $eachResult["CountryCode"], 1, 0, 'C');
$this->Cell(20, 6, $eachResult["Budget"], 1);
$this->Cell(20, 6, $eachResult["Budget"], 1);
$this->Ln();
}
}
function personsql($cond, $id)
{
$sql = "SELECT DISTINCT *
FROM personal AS p
left JOIN education E ON E.`id_personal` = p.`id_personal`
left JOIN experience Ex ON EX.`id_personal` = p.`id_personal`
left JOIN certification c ON c.`id_personal` = p.`id_personal`
left JOIN images i ON i.`id_personal` = p.`id_personal`
left JOIN jobpost j ON j.`id_job` = p.`id_job`
where p.id_personal = $id ";
$query = mysqli_query($cond, $sql);
$result = array();
while ($obResult = mysqli_fetch_assoc($query)) {
array_push($result, $obResult);
}
return $result;
}
}
/*A4 width : 219mm*/
$pdf = new FPDF('P', 'mm', 'A4');
$header=array('CustomerID','Name','Email','Country Code','Budget','Used');
$header = iconv('UTF-8', 'TIS-620', "$header");
$servername = "localhost";
$cond = mysqli_connect($servername, $username, $password, $database);
$pdf->BasicTable($header, $resultData);
$pdf->AddPage();
/*output the result*/
$pdf->AddFont('THSarabunNew', '', 'THSarabunNew.php');
/*set font to arial, bold, 14pt*/
/*Cell(width , height , text , border , end line , [align] )*/
$pdf->SetFont('THSarabunNew', '', 50);
$pdf->Cell(71, 10, '', 0, 0);
$pdf->Output();
?>

ทำไมถึงแดงเหรอครับ
แล้วถ้าผมต้องการเรียกใช้ function personsql นี่ผมต้องอ้างอิงยังไงครับ
Tag : PHP, MySQL, PDF

|
|
 |
 |
 |
 |
Date :
2021-05-26 23:22:35 |
By :
prorioo |
View :
721 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอนสร้างออปเจกคุณอิงคลาสแม่ซึ่งไม่มีฟังก์ชันที่ถูกสร้างขึ้นใหม่
$pdf = new FPDF('P', 'mm', 'A4'); //คลาสแม่
ต้องสร้างออปเจกจากคลาสลูกจึงจะมีฟังก์ชั่นเหล่านี้และเรียกใช้งานได้
|
 |
 |
 |
 |
Date :
2021-05-27 07:39:36 |
By :
พญามัจจุราช |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|