$query = "SELECT * FROM final WHERE Quote LIKE $quotation ORDER BY finalID";
$result = mysql_query($query) or die("Couldn't execute query");
while($row = mysql_fetch_array($result))
{
$PresID = $row['PresID'];
$ProdQuan= $row['ProdQuan'];
$ProdFinish = $row['ProdFinish'];
$ProdPrice = $row['ProdPrice'];
$linevalue = $ProdQuan*$ProdPrice;
$linevalue = number_format($linevalue, 2);
$linevalue = "£" . $linevalue;
$ProdPrice = number_format($ProdPrice, 2);
$ProdPrice = "£" . $ProdPrice;
$description = $row['datadesc'];
$dim = $row['ProdDim'];
$image = $row['imageindex'];
$model = $row['ProdModel'];
$Dimchange = str_replace("<br />","\n",$dim);
$desctxt = $description . "\n\nW x D x H (Seat Height) c.m.:\n" . $Dimchange . "\n\n" . $ProdFinish;
$y_axis = ($y_axis+6) + $h;
$pdf->SetY($y_axis);
$pdf->SetX(15);
$pdf->SetFont('Arial','',10);
$pdf->SetAligns(array(L,L,R,R,R));
$pdf->SetWidths(array(61,61,12,20,25));
$pdf->Row(array(strtoupper($model),$desctxt,$ProdQuan,$ProdPrice,$linevalue));
}
mysql_close();//Create file
$file =''.$quotation.'.pdf';
$pdf->Output($file);
echo "<HTML><SCRIPT>document.location.href='http://www.mysite.co.uk/tmp3/$file';</SCRIPT></HTML>";
This is part of the code that generates the pdf's which generate no problem. The height is calculated within the Row function and this function looks like this
function Row($data)
{
//Calculate the height of the row
global $h;
$nb=0;
for($i=0;$i<count($data);$i++)
$nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
$h=5*$nb;
//Issue a page break first if needed
$this->CheckPageBreak($h);
//Draw the cells of the row
for($i=0;$i<count($data);$i++)
{
$w=$this->widths[$i];
$a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
//Save the current position
$x=$this->GetX();
$y=$this->GetY();
//Draw the border
$this->Rect($x,$y,$w,$h);
//Print the text
$this->MultiCell($w,5,$data[$i],0,$a);
//Put the position to the right of the cell
$this->SetXY($x+$w,$y);
}
//Go to the next line
$this->Ln($h);
}
I am sure that there is some redundant code there, but it does work fine as well. However, the $h variable which defines the height of the row within the function, I have made global so that I can use it outside the function back in the code at the top. I can echo the last height, but what I need is the array of heights from the while loop so that I can start to work with the data and then calculate page breaks etc on the fly. It is ridiculous, buut it is a problem with learning php on an ad hoc basis that you can miss what now seems to be fundamental stuff like this. I am aware that the function produces rows as well, but all I need is the one row that it does produce per row from the while statement. I hope that there is not too much rubbish to work out what I am on about.