<?php
require('fpdf.php');
include("dbConfig.php");
$CUST_ID ="3000/001";
$result = mysql_query("SELECT * FROM com_profile WHERE CUST_ID = '$CUST_ID'");
while ($row = mysql_fetch_array($result)) {
$CUST_NAME = $row["CUST_NAME"];
$CUST_NAME2 = $row["CUST_NAME2"];
$CUST_TEL = $row["CUST_TEL"];
$CUST_FAX = $row["CUST_FAX"];
$CUST_EMAIL = $row["CUST_EMAIL"];
}
$CUST_NAME = htmlspecialchars_decode($CUST_NAME) ;
$CUST_NAME2 = htmlspecialchars_decode($CUST_NAME2);
$CUST_TEL = htmlspecialchars_decode($CUST_TEL);
$CUST_FAX = htmlspecialchars_decode($CUST_FAX);
$CUST_EMAIL = htmlspecialchars_decode($CUST_EMAIL);
/**
* header and footer for pdf
*/
class PDF extends FPDF
{
}
// Instantiation of inherited class
$pdf = new PDF('L', 'mm', 'A4');
$pdf -> AliasNbPages();
$pdf -> SetTitle("Point History");
$pdf -> AddPage();
$pdf -> SetFont('Times', 'U', 16);
$pdf -> Cell(5);
$pdf -> Cell(30,10,'Point Transactions:');
$pdf ->SetFont('Times', 'B', 12);
$pdf -> Ln(5);
$pdf -> Cell(10);
$pdf -> Cell(35,10, 'Company Code :');
$pdf ->SetFont('Times', '', 12);
$pdf -> Cell(30, 10, $CUST_ID);
$pdf -> Ln(5);
$pdf -> Cell(10);
$pdf ->SetFont('Times', 'B', 12);
$pdf -> Cell(35,10, 'Company Name :');
$pdf ->SetFont('Times', '', 12);
$pdf -> Cell(30, 10, $CUST_NAME);
$pdf ->Ln(5);
$pdf ->Cell(45);
$pdf -> Cell(30, 10, $CUST_NAME2);
$pdf -> Ln(5);
$pdf -> Cell(10);
$pdf ->SetFont('Times', 'B', 12);
$pdf -> Cell(35,10, 'Tel :');
$pdf ->SetFont('Times', '', 12);
$pdf -> Cell(30, 10, $CUST_TEL);
$pdf -> Ln(5);
$pdf -> Cell(10);
$pdf ->SetFont('Times', 'B', 12);
$pdf -> Cell(35,10, 'Fax :');
$pdf ->SetFont('Times', '', 12);
$pdf -> Cell(30, 10, $CUST_FAX);
$pdf -> Ln(5);
$pdf -> Cell(10);
$pdf -> SetFont('Times', 'B', 12);
$pdf -> Cell(35,10, 'Email :');
$pdf ->SetFont('Times', '', 12);
$pdf -> Cell(30, 10, $CUST_EMAIL);
$pdf -> Ln(15);
$pdf -> Cell(5);
$pdf -> SetFont('Times', 'B', 10);
$pdf -> SetDrawColor(50,50,100);
$pdf -> Cell(155,8,'SERVICE DESCRIPTION', 1,0,'',false);
$pdf -> Cell(20,8,'POINT(-)', 1,0,'',false);
$pdf -> Cell(20,8,'POINT(+)', 1,0,'',false);
$pdf -> Cell(20,8,'BALANCE', 1,0,'',false);
$pdf -> Cell(25,8,'DATE', 1,0,'',false);
$pdf -> Cell(25,8,'SERV. BY', 1,1,'',false);
$pdf -> SetFont('Times', '', 10);
// query to retrieve data from database
$result = mysql_query("SELECT * FROM point_histories WHERE CUST_ID = '$CUST_ID' ORDER BY CON_ID ASC");
$Y = 63;
while ($row = mysql_fetch_array($result)) {
$pdf -> SetXY(15, $Y);
$pdf -> MultiCell(155,8,$row['SERVICE_DESP'], 1,"L");
$H = $pdf -> GetY();
$height = $H - $Y;
$pdf -> SetXY(170, $Y);
$pdf -> Cell(20,$height,$row['P_DEDUCTED'], 1,"L");
$pdf -> SetXY(190, $Y);
$pdf -> Cell(20,$height,$row['P_ADDED'], 1,"L");
$pdf -> SetXY(210, $Y);
$pdf -> Cell(20,$height,$row['P_BALANCES'], 1,"L");
$pdf -> SetXY(230, $Y);
$pdf -> Cell(25,$height,$row['MODIFIED_DATE'], 1,"L");
$pdf -> SetXY(255, $Y);
$pdf -> Cell(25,$height,$row['TC_SUPPORT'], 1, "L");
$Y = $H;
}
$pdf -> Output();
?>
I trying to generate fpdf table that loads data from MySQL table, when the content can fit inside one page, table is fine. But when the content need to extends to second page, the table column disoriented just like shown in the attached pic. I know that it has something to do with the y-axis but I don't know how to fix this, can someone help?