1
<?php
$factuurnr = $_GET['factuurnr'];
require('fpdf/fpdf.php');
//Connect to your database
include("db_connect.php");
//Create new pdf file
$pdf=new FPDF();
//Open file
$pdf->Open();
//Disable automatic page break
$pdf->SetAutoPageBreak(false);
//Add first page
$pdf->AddPage();
//set initial y axis position per page
$y_axis_initial = 25;
//print column titles for the actual page
$pdf->SetFillColor(232, 232, 232);
$pdf->SetFont('Arial', 'B', 12);
$pdf->SetY($y_axis_initial);
$pdf->SetX(25);
$pdf->Cell(30, 6, 'klantnummer', 1, 0, 'L', 1);
$pdf->Cell(100, 6, 'factuurnummer', 1, 0, 'L', 1);
$pdf->Cell(30, 6, 'bedrag', 1, 0, 'R', 1);
$y_axis = $y_axis + $row_height;
//Select the Products you want to show in your PDF file
$query="SELECT * FROM facturen WHERE factuurnummer = '$factuurnr'";
$result=mysql_query($query);
//initialize counter
$i = 0;
//Set maximum rows per page
$max = 25;
//Set Row Height
$row_height = 6;
while($row = mysql_fetch_array($result))
{
//If the current row is the last one, create new page and print column title
if ($i == $max)
{
$pdf->AddPage();
//print column titles for the current page
$pdf->SetY($y_axis_initial);
$pdf->SetX(25);
$pdf->Cell(30, 6, 'klantnummer', 1, 0, 'L', 1);
$pdf->Cell(100, 6, 'factuurnummer', 1, 0, 'L', 1);
$pdf->Cell(30, 6, 'bedrag', 1, 0, 'R', 1);
//Go to next row
$y_axis = $y_axis + $row_height;
//Set $i variable to 0 (first row)
$i = 0;
}
$klantnummer = $row['klantnummer'];
$factuurnummer = $row['factuurnummer'];
$bedrag = $row['bedrag'];
$pdf->SetY($y_axis);
$pdf->SetX(25);
$pdf->Cell(30, 6, $klantnummer, 1, 0, 'L', 1);
$pdf->Cell(100, 6, $factuurnummer, 1, 0, 'L', 1);
$pdf->Cell(30, 6, $bedrag, 1, 0, 'R', 1);
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
}
mysql_close;
//Create file
$pdf->Output();
?>
저는 fpdf를 사용하여 MySQL의 정보로 pdf를 생성하려고합니다. 솔직하게 말하면, 렌더링은 꺼져 있지만, 나는 이것을 이해하기에는 너무 초보이다.FPDF에서 렌더링을 향상시키는 방법은 무엇입니까?
MySQL의 데이터가 표 머리글 위에 렌더링되고, 그 이유를 모르겠습니다.
[** 새 코드 **에서 mysql_ * 함수를 사용하지 마십시오 (http://bit.ly/phpmsql). 더 이상 유지 관리되지 않으며 공식적으로 사용되지 않습니다 (https://wiki.php.net/rfc/mysql_deprecation). [** 빨간색 상자 **] (http://j.mp/Te9zIL)를 참조하십시오. 대신 [* prepared statements *] (http://j.mp/T9hLWi)에 대해 알아보고 [PDO] (http://php.net/pdo) 또는 [MySQLi] (http://php.net/)를 사용하십시오. mysqli) - [이 기사] (http://j.mp/QEx8IB)는 어떤 결정을 내리는 데 도움이 될 것입니다. PDO를 선택하면 [여기는 좋은 튜토리얼입니다] (http://www.brightmeup.info/article.php?a_id=2). 더 이상 사용되지 않는 정보를 가리키고있는 –
thnx 및 Thyx 남자 – defiancenl