Salve a tutti, sto cercando di capire come realizzare un pdf attraverso fpdf...e il risultato è il codice sottostante. PROBLEMA: mi stampa solo una pagina con il primo record, mentre io vorrei che venisse prodotta una pagina per ogni record... inoltre vorrei inserire un'altra query che visualizzi un testo (uguale per tutti gli indirizzi, quindi in ogni pagina) dal database dove il campo contiene dei tag html... è possibile farlo?


Codice PHP:
<?php
include("db.php");
//print ($_REQUEST['query']."
");
$server = "localhost";
$utente = "";
$db_pass = "";
$datab = "";

$connessione = mysql_connect($server$utente$db_pass)
                                 or die (errore_server ());
$db = mysql_select_db($datab$connessione
                                  or die (errore_server ());


require('fpdf/fpdf.php');


define('FPDF_FONTPATH','fpdf/font/');
require_once('fpdf/pdflabel.php');

/*-------------------------------------------------
To create the object, 2 possibilities:
either pass a custom format via an array
or use a built-in AVERY name
-------------------------------------------------*/

// Example of custom format; we start at the second column
$pdf = new PDF_Label(array('name'=>'perso1', 'paper-size'=>'A4', 'marginLeft'=>1, 'marginTop'=>1, 'NX'=>3, 'NY'=>8,
 'SpaceX'=>6, 'SpaceY'=>6, 'width'=>66, 'height'=>38.1, 'metric'=>'mm', 
'font-size'=>10), 3, 0);
// Standard format
//
$pdf = new PDF_Label('L7163', 'mm', 1, 1);

$pdf->Open();
//
$pdf->AddPage();

// Print labels

//
$now = getdate();
//
$anno_now = $now['year'];
include("
paging.func.php");  
if (
$_REQUEST["tipo"] == 'pro'){
   
$titolo = "PROFESSIONISTI";}
  elseif (
$_REQUEST["tipo"] == 'pra'){
   
$titolo = "PRATICANTI";}
elseif (
$_REQUEST["tipo"] == 'pub'){
   
$titolo = "PUBBLICISTI";}
elseif (
$_REQUEST["tipo"] == 'spe'){
   
$titolo = "SPECIALE";}
else{
   print "
<h1>ERRORE CODICE LISTA </h1>
";
}
$res = paging("SELECT id_asscognome_nomeconcat
(indirizzo_res,'
'
,cap_res,'',comune_res,'','(',prov_res,')') as
 
indirizzoresidenzaconcat(indirizzo_dom,',',cap_dom,'-',comune_dom,'-','(',prov_dom,')') as
 
indirizzodomicilioselezione_indselezione_ind2
FROM anagrafica WHERE 
(".$_REQUEST["tipo"]."_dataiscr !=0000-00-00)
 
ORDER BY cognome_nome"); 
$i = 0;
if (!
$res[0]) { echo "non ci sono dati";} 
else 
 { 
   while(
$dati = mysql_fetch_array($res[0])) 
     { 
  if (
$dati["selezione_ind"] == "res"){
        
$pdf->Add_PDF_Label(sprintf("$dati[cognome_nome]$dati[indirizzoresidenza]"));
      
$i++;   

                }
        elseif (
$dati["selezione_ind2"] == "dom"){
       
$pdf->Add_PDF_Label(sprintf("$dati[cognome_nome]$dati[indirizzodomicilio]"));
      
$i++;   
      }
         }
         }

$pdf->Output();
?>