Codice PHP:
<?php
session_start();
$cod_cond = $_SESSION['cod_cond'];
$Denominazione = $_SESSION['Denominazione'];
define('FPDF_FONTPATH','./font/font_');
require('fpdf.php');
//Connect to your database
//include("conectmysql.php");
$server = "localhost";
$utente = "";
$password = "";
$datab = "Gestione";
$link = mysql_connect($server,$utente,$password)
or die
("
[b]Non posso connettrmi al Server[/b]
".mysql_error());
$conn=mysql_select_db($datab, $link) or die("
[b]Non riesco a connettermi al Database.[/b]
".mysql_error());
//Create new pdf file
$pdf=new FPDF();
//Disable automatic page break
$pdf->SetAutoPageBreak(false);
//Add first page
$pdf->AddPage();
//set initial y axis position per page
$y_axis_initial = 15;
//print column titles
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',10);
$pdf->SetY($y_axis_initial);
$pdf->SetX(10);
$pdf->Cell(40,6,'COGNOME',1,0,'L',1);
$pdf->Cell(40,6,'NOME',1,0,'L',1);
$pdf->Cell(40,6,'INDIRIZZO',1,0,'R',1);
$y_axis = $y_axis_initial + $row_height;
//Select the Products you want to show in your PDF file
$result=mysql_query("select anag.Cognome,anag.Nome,immob.interno_immob from anag,immob where (anag.Id_Anag=id_anag_immob and '$cod_cond'=immob.cod_cond)",$link);
//initialize counter
$i = 0;
//Set maximum rows per page
$max = 25;
//Set Row Height
$row_height = 6;
while($row = mysql_fetch_array($result))
{
//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(10);
$pdf->Cell(40,6,'COGNOME',1,0,'L',1);
$pdf->Cell(40,6,'NOME',1,0,'L',1);
$pdf->Cell(40,6,'INDIRIZZO',1,0,'R',1);
//Go to next row
$y_axis = $y_axis + $row_height;
//Set $i variable to 0 (first row)
$i = 0;
}
$cognome = $row['Cognome'];
$nome = $row['Nome'];
// $indirizzo = $row['Indirizzo'];
$pdf->SetY($y_axis);
$pdf->SetX(10);
$pdf->Cell(40,6,$cognome,1,0,'L',1);
$pdf->Cell(40,6,$nome,1,0,'L',1);
$pdf->Cell(40,6,$indirizzo,1,0,'R',1);
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
}
mysql_close($link);
//Send file
$pdf->Output("lista_condomini.pdf",'I');
?>