fpdf มันรันไม่ขึ้นบรรทัดเดียว ดึงมาจากฐานข้อมูล คอมเม้นไว้ในโค๊ด


ช่วยหน่อยครับ function header() title ดีงจากฐานข้อมูลครับ

<?php


include('../../inc/connect.php');


require('../report/fpdf.php');


$reportpa=$_GET['part_id'];


$reportac=$_GET['act_id'];


$strSQL2 = "SELECT * from participants LEFT JOIN activity ON participants.part_id=activity.act_id where part_id='$reportac' ";


$objQuery1 = mysql_query($strSQL2);


while($objResult1 = mysql_fetch_array($objQuery1))


{


$title = iconv('UTF-8', 'TIS-620',$objResult1["act_name"]);


// $pdf->Cell(110,-30,$title,0,0,'C');


// $pdf->Ln(1);


}


//ทำการสืบทอดคลาส FPDF ให้เป็นคลาสใหม่


class PDF extends FPDF


{


//Override คำสั่ง (เมธอด) Header


function Header(){


require('../../inc/connect.php');


$this->AddFont('angsana','','angsa.php');


  $this->AddFont('angsana','B','angsab.php');


$this->Image('../report/logo.jpg',90,12,30,0,'','');


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


$this->Cell(110,-15,iconv('UTF-8', 'TIS-620','โครงการพัฒนาป่าชุมชน บ้านอ่างเอ็ด'),0,0,'C');


$this->Ln(10);


$this->Cell(110,-20,iconv('UTF-8', 'TIS-620','ตำบลตกพรม อำเภอขลุง จังหวัดจันทบุรี'),0,0,'C');


$this->Ln(10);


$this->Cell(110,-25,iconv('UTF-8', 'TIS-620','รายชื่อผู้เข้าร่วมกิจกรรม'),0,0,'C');


$this->Ln(15);


//บรรทัดข้างล่างนี้ไม่ขึ้นบรรทัดเดียวครับ


$this->Cell(110,-30,$title,0,0,'C');


$this->Ln(1);




//Override คำสั่ง (เมธอด) Footer


function Footer()


//นับจากขอบกระดาษด้านล่างขึ้นมา 10 มม.


$this->SetY( -10 ); 


//กำหนดใช้ตัวอักษร Arial ตัวเอียง ขนาด 5


$this->SetFont('Arial','I',5); 


//พิมพ์วัน-เวลา ตรงมุมขวาล่าง


//$this->Cell(0,10,'Time '. date('d').'/'. date('m').'/'.(  date('Y')+543 ).' '. date('H:i:s') ,0,0,'L'); 


//$this->Cell(0,10, 'page '.$this->PageNo().' of  tp' ,0,0,'R');


}


//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(10,30,25,25,20);


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


$this->Cell($w[$i],7,iconv('UTF-8', 'TIS-620', $header[$i]),1,0,'C');


   $this->Ln();


//Data


$num=1; //ลำดับที่ 123 


$i=0;


$row=30;#Max rows of first page.


foreach ($data as $eachResult) 


{


$i=$i+1;


$this->Cell(10,6,iconv('UTF-8', 'TIS-620', $num),1,0,'C');


$this->Cell(30,6,iconv('UTF-8', 'TIS-620', $eachResult["part_name"]),1,0,'L');


$this->Cell(25,6,iconv('UTF-8', 'TIS-620', $eachResult["part_last_name"]),1,0,'L');


$this->Cell(25,6,iconv('UTF-8', 'TIS-620', $eachResult["part_phone"]),1,0,'C');


$this->Cell(20,6,'',1,0,'C');


$this->Ln();


if ($i%$row==0){


$this->AddPage();


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


$this->Cell($w[$i],7,iconv('UTF-8', 'TIS-620', $header[$i]),1,0,'C');


  $this->Ln();


$i=0;


$row=30;


}


$num++; 


  }


   }




$pdf=new PDF();//เรียกใช้งาน เราจะเรียกใช้คลาสใหม่ของเราแทน


//เพิ่ม font เข้ามาในเอกสาร


$pdf->AddFont('angsana','','angsa.php');


  $pdf->AddFont('angsana','B','angsab.php');


//Column titles


$header=array('ลำดับ','ชื่อ','สกุล','เบอร์โทรศัพท์','หมายเหตุ');


$strSQL = "SELECT * from participants where act_id='$reportpa' ";


$objQuery = mysql_query($strSQL);


$resultData = array();


for ($i=0;$i<mysql_num_rows($objQuery);$i++) {


$result = mysql_fetch_array($objQuery);


array_push($resultData,$result);


}


//*** Table 1 ***//


$pdf->SetMargins(50,50,10);//กำหนด Margin


$pdf->AddPage();//เพิ่มหน้า


$pdf->AliasNbPages( 'tp' );//แสดงเลขหน้า


$pdf->BasicTable($header,$resultData);


$pdf->Output();


?>

06 ส.ค. 2555 3 5,561

แก้ไขได้แล้วครับ สามารถลบกระทู้นี้ได้เลยครับ
#1

แก้ไขไงอะคับ บอกที่ติดเหมือนกัน
#2

แก้ไขไงอะคับ บอกที่ติดเหมือนกัน
#3
ความคิดเห็น
ไฟล์อัปโหลด ชนิด jpg, jpeg ขนาดไฟล์ไม่เกิน 1024
^