Buongiorno a tutti.
sto cercando di fare dei pdf dinamici e utilizzo le librerie fpdf.
vorrei estrarre in un pdf i dati relativi all'utente che in quel momento risulta loggato.
ad ora il codice che vi allego mi restituisce tutti gli utenti registrati.

<?php
require('mysql_table.php');

$pdf = new PDF('L','pt','A3');
$pdf->SetFont('Arial','',11.5);
$pdf->connect('localhost','root','idaelisabetta','login ');
$pdf->mysql_report("SELECT name,lastname,luogonascita,provincia,datanascita,r esidenza,indirizzo FROM login_cliente LIMIT 100",false,$attr);
$pdf->Output();
?>

<?php
require('fpdf.php');

class PDF extends FPDF {

var $tablewidths;
var $headerset;
var $footerset;




function morepagestable($lineheight=8) {
// some things to set and 'remember'
$l = $this->lMargin;
$startheight = $h = $this->GetY();
$startpage = $currpage = $this->page;

// calculate the whole width


// Now let's start to write the table
$row = 0;
while($data=mysql_fetch_row($this->results)) {
$this->page = $currpage;
// write the horizontal borders
$this->Line($l,$h,$fullwidth+$l,$h);
// write the content and remember the height of the highest col
foreach($data as $col => $txt) {

$this->page = $currpage;
$this->SetXY($l,$h);
$this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,$this->colAlign[$col]);

$l += $this->tablewidths[$col];

if($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
$tmpheight[$row.'-'.$this->page] = $this->GetY();
}
if($this->page > $maxpage)
$maxpage = $this->page;
unset($data[$col]);
}
// get the height we were in the last used page
$h = $tmpheight[$row.'-'.$maxpage];
// set the "pointer" to the left margin
$l = $this->lMargin;
// set the $currpage to the last page
$currpage = $maxpage;
unset($data[$row]);
$row++ ;
}
// draw the borders
// we start adding a horizontal line on the last page



// set it to the last page, if not it'll cause some problems

}

function connect($host='localhost',$username='',$password=' ',$db=''){
$this->conn = mysql_connect($host,$username,$password) or die( mysql_error() );
mysql_select_db($db,$this->conn) or die( mysql_error() );
return true;
}

function query($query){
$this->results = mysql_query($query,$this->conn);
$this->numFields = mysql_num_fields($this->results);
}



function mysql_report($query,$dump=false,$attr=array()){



$this->query($query);

// if column widths not set
if(!isset($this->tablewidths)){

// starting col width
$this->sColWidth = (($this->w-$this->lMargin-$this->rMargin))/$this->numFields;

// loop through results header and set initial col widths/ titles/ alignment
// if a col title is less than the starting col width / reduce that column size


// loop through the data, any column whose contents is bigger that the col size is
// resized
while($row=mysql_fetch_row($this->results)){



}



$surplus = (sizeof($colFits)*$this->sColWidth) - ($totAlreadyFitted);
for($i=0;$i<$this->numFields;$i++){
if(!in_array($i,array_keys($colFits))){
$this->tablewidths[$i] = $this->sColWidth + ($surplus/(($this->numFields)-sizeof($colFits)));
}
}



if($dump){
Header('Content-type: text/plain');
for($i=0;$i<$this->numFields;$i++){
if(strlen(mysql_field_name($this->results,$i))>$flength){
$flength = strlen(mysql_field_name($this->results,$i));
}
}
switch($this->k){
case 72/25.4:
$unit = 'millimeters';
break;
case 72/2.54:
$unit = 'centimeters';
break;
case 72:
$unit = 'inches';
break;
default:
$unit = 'points';
}
print "All measurements in $unit\n\n";
for($i=0;$i<$this->numFields;$i++){
printf("%-{$flength}s : %-10s : %10f\n",
mysql_field_name($this->results,$i),
mysql_field_type($this->results,$i),
$this->tablewidths[$i] );
}
print "\n\n";
print "\$pdf->tablewidths=\n\tarray(\n\t\t";
for($i=0;$i<$this->numFields;$i++){
($i<($this->numFields-1)) ?
print $this->tablewidths[$i].", /* ".mysql_field_name($this->results,$i)." */\n\t\t":
print $this->tablewidths[$i]." /* ".mysql_field_name($this->results,$i)." */\n\t\t";
}
print "\n\t);\n";
exit;
}

} else { // end of if tablewidths not defined

for($i=0;$i<$this->numFields;$i++){
$this->colTitles[$i] = mysql_field_name($this->results,$i) ;
switch (mysql_field_type($this->results,$i)){
case 'int':
$this->colAlign[$i] = 'R';
break;
default:
$this->colAlign[$i] = 'L';
}
}
}

mysql_data_seek($this->results,0);
$this->AliasNbPages();
$this->SetY($this->tMargin);
$this->AddPage();
$this->morepagestable($this->FontSizePt);
}

}
?>

Grazie mille....