Я использовал Fpdf для получения данных из моей базы данных и загрузки их в формате PDF. Вот мой код и результат. Мне не нужен такой формат:
Однако я хочу отобразить свою таблицу, как показано здесь:
Между таблицами есть знак ----, поскольку он получает все записи из базы данных. Как я могу это сделать? Мой Engli sh не очень хорошо, поэтому я загрузил изображения, чтобы убедиться, что я показываю то, что я хочу. Спасибо за ваше время. Вот мой код: `
<?php
//include connection file
include_once("connection.php");
include_once('fpdf.php');
$db = new PDO ('mysql:host=localhost;dbname=son_fbe','root','');
class myPDF extends FPDF
{
// Page header
function Header()
{
// Logo
// $this->Image('alpacino.png',10,-1,70);
$this->SetFont('Arial','B',13);
// Move to the right
$this->Cell(80);
// Title
$this->Cell(80,10,'Ders Saydirma',1,0,'C');
// Line break
$this->Ln(20);
}
// Page footer
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
function headerTable(){
$this -> SetFont('Times','B',12);
$this ->Cell(50,10,'Gonderilen',1,0,'C');
$this ->Cell(35,10,' Gonderen',1,0,'C');
$this ->Cell(35,10,' O_ AdSoyad',1,0,'C');
$this ->Cell(30,10,' Ogrenci No',1,0,'C');
$this -> Ln();
}
function viewTable($db){
$this -> SetFont('Times','',12);
$stmt = $db -> query('select*from derssaydirma');
while($data = $stmt -> fetchObject()){
$this ->Cell(50,10,$data-> Gonderilen,1,0,'L');
$this ->Cell(35,10,$data-> Gonderen,1,0,'L');
$this ->Cell(35,10,$data-> O_AdiSoyadi,1,0,'L');
$this ->Cell(30,10,$data-> OgrenciNo,1,0,'L');
$this -> Ln();
}
}
}
$pdf = new myPDF();
$pdf->AliasNbPages();
$pdf->AddPage('L','A4',0);
$pdf->SetFont('Arial','B',12);
$pdf -> headerTable();
$pdf -> viewTable($db);
$pdf->Output();
?>
`