...

View Full Version : struggling to print selected data in a table to pdf



cswart777
09-12-2011, 03:26 PM
Good Day,

Please can anyone assist i'm trying to print a table with only selected query's data to pdf using fpdf, my pdf runs but doesn't display the table data.



$query_rsSpectra = "SELECT *
FROM spectra
INNER JOIN detai
USING (sfref)
WHERE spectra.sfref = 'SPM0001'";
$rsSpectra = mysql_query($query_rsSpectra, $spectra) or die(mysql_error());
$row_rsSpectra = mysql_fetch_assoc($rsSpectra);

if (isset($_GET['totalRows_rsSpectra'])) {
$totalRows_rsSpectra = $_GET['totalRows_rsSpectra'];
} else {
$all_rsSpectra = mysql_query($query_rsSpectra);
$totalRows_rsSpectra = mysql_num_rows($all_rsSpectra);
}
while($row_rsSpectra = mysql_fetch_assoc($all_rsSpectra))
{
$pdf = new FPDF('L', 'mm', 'A4');
$pdf -> AddPage();
$pdf -> SetFont ('Arial','B', 10);
$pdf-> Image('xdsl.jpg',10,6,50);
$pdf-> Image('GL.jpg',240,6,35);
$pdf -> Ln(40);
$pdf -> Cell (25,5,"Reference :");
$pdf -> Cell (80,5,$row_rsSpectra['sfref'] ,1);
$pdf -> Cell (80,5,$row_rsSpectra['claimnumber'] ,1);
$pdf -> Ln(40);
$pdf -> Cell (80,5,$row_rsSpectra['surnam'] ,1);
$pdf -> Ln(40);
//initialize counter
$i = 0;

//Set maximum rows per page
$max = 25;

//Set Row Height
$row_height = 6;

while($row = mysql_fetch_array($all_rsSpectra))
{
//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,'Claim',1,0,'L',1);
$pdf->Cell(100,6,'Provider',1,0,'L',1);
$pdf->Cell(30,6,'Paid Supplier',1,0,'R',1);
//Set $i variable to 0 (first row)
$i = 0;
}

$claim = $all_rsSpectra['claimnumber'];
$name = $all_rsSpectra['providername'];
$supplier = $all_rsSpectra['paidsuppl'];

$pdf->SetY(5);
$pdf->SetX(25);
$pdf->Cell(30,6,$claim,1,0,'L',1);
$pdf->Cell(100,6,$supplier,1,0,'L',1);
$pdf->Cell(30,6,$name,1,0,'R',1);

//Go to next row
$i = $i + 1;
}
//mysql_close($link);
$pdf -> Output($row_rsSpectra['sfref'], 'I');
}
?>

tangoforce
09-12-2011, 04:32 PM
With 5 posts you've surely had time to read the sticky topic about [php] tags?

If not there is a link in my signature.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum