Hi Brad & Derokorian,
Many thanks for your replies.
I was trying to cut down the code which I thought was giving me the issue, so here I have included the complete script which may make it better to follow.
The script is to output data to a PDf file.
Again thanks for your help.
if(!isset($_SESSION)) {
session_start();
}
require_once('../Connections/conn.php');
mysql_select_db($database_nave, $conn);
$query_SMS_Report = "SELECT DateStamp, MobileNo, FlightNo, AD, IATALookup, CreditsUsed FROM FlightX_Credits_Used WHERE ParentID = 2 order by DateStamp";
$SMS_Report = mysql_query($query_SMS_Report, $conn) or die(mysql_error());
$row_SMS_Report = mysql_fetch_assoc($SMS_Report);
$totalRows_SMS_Report = mysql_num_rows($SMS_Report);
require_once( "fpdf.php" );
// Begin configuration
$textColour = array( 0, 0, 0 );
$headerColour = array( 100, 100, 100 );
$tableHeaderTopTextColour = array( 255, 255, 255 );
$tableHeaderTopFillColour = array( 125, 152, 179 );
$tableHeaderTopProductTextColour = array( 0, 0, 0 );
$tableHeaderTopProductFillColour = array( 143, 173, 204 );
$tableHeaderLeftTextColour = array( 99, 42, 57 );
$tableHeaderLeftFillColour = array( 184, 207, 229 );
$tableBorderColour = array( 50, 50, 50 );
$tableRowFillColour = array( 213, 170, 170 );
$reportName = "FlightX Usage Report";
$reportNameYPos = 160;
$logoFile = "navex_logo.jpg";
$logoXPos = 50;
$logoYPos = 50;
$logoWidth = 50;
$columnLabels = array( "Date", "Mobile No", "Flight No", "A/D", "City", "Credit Used" );
$data = array($row_SMS_Report);
// End configuration
/**
Create the title page
**/
$pdf = new FPDF( 'P', 'mm', 'A4' );
$pdf->SetTextColor( $textColour[0], $textColour[1], $textColour[2] );
$pdf->AddPage();
// Logo
$pdf->Image( $logoFile, $logoXPos, $logoYPos, $logoWidth );
// Report Name
$pdf->SetFont( 'Arial', 'B', 14 );
$pdf->Ln( $reportNameYPos );
$pdf->Cell( 0, 15, $reportName, 0, 0, 'C' );
/**
Create the table
**/
$pdf->SetDrawColor( $tableBorderColour[0], $tableBorderColour[1], $tableBorderColour[2] );
$pdf->Ln( 15 );
// Create the table header row
$pdf->SetFont( 'Arial', 'B', 12 );
// "HEADER" cell
$pdf->SetTextColor( $tableHeaderTopProductTextColour[0], $tableHeaderTopProductTextColour[1], $tableHeaderTopProductTextColour[2]);
$pdf->SetFillColor( $tableHeaderTopProductFillColour[0], $tableHeaderTopProductFillColour[1], $tableHeaderTopProductFillColour[2] );
// Remaining header cells
$pdf->SetTextColor( $tableHeaderTopTextColour[0], $tableHeaderTopTextColour[1], $tableHeaderTopTextColour[2] );
$pdf->SetFillColor( $tableHeaderTopFillColour[0], $tableHeaderTopFillColour[1], $tableHeaderTopFillColour[2] );
for ( $i=0; $i<count($columnLabels); $i++ ) {
$pdf->Cell( 36, 12, $columnLabels[$i], 1, 0, 'C', true );
}
$pdf->Ln( 12 );
// Create the table data rows
$fill = false;
$row = 0;
foreach ( $data as $dataRow ) {
// Create the data cells
$pdf->SetTextColor( $textColour[0], $textColour[1], $textColour[2] );
$pdf->SetFillColor( $tableRowFillColour[0], $tableRowFillColour[1], $tableRowFillColour[2] );
$pdf->SetFont( 'Arial', '', 12 );
for ( $i=0; $i<count($columnLabels); $i++ ) {
$pdf->Cell( 36, 12, $dataRow[$i], 1, 0, 'C', $fill );
}
$row++;
$fill = !$fill;
$pdf->Ln( 12 );
}
/***
Serve the PDF
***/
$pdf->Output( "report.pdf", "I" );