Codice PHP:
require('fpdf.php');
session_start();
$strSql=$_SESSION['strSql'];
$dataMese = $_SESSION['DataMese'];
$dataAnno = $_SESSION['DataAnno'];
$nomeMese = array(Gennaio, febbraio, Marzo, Aprile, Maggio, Giugno, Luglio, Agosto, Settembre, Ottobre, Novembre, Dicembre);
$nomeMese[$dataMese];
global $nomeMese;
//stabilire la connessione
$conn = mysqli_connect("localhost","zappellini","");
if ($conn->connect_errno)
{
echo "Connessione fallita: ". $conn->connect_error . ".";
exit();
}
//selezionare il db
mysqli_select_db($conn,"my_zappellini");
// creo il pdf
class PDF extends FPDF
{
// Page header
function Header()
{
// Arial bold 15
$this->SetFont('Arial','B',16);
// Move to the right
$this->Cell(80);
// Title
$this->Cell(30,10,'Lista elenco Note',0,0,'C');
$this->Ln(10);
$this->Cell(80);
$this->Cell(30,10,$nomeMese,0,0,'C');
// Line break
$this->Ln(20);
//intestazione colonne
$this->SetFont('Arial','B',12);
$this->Cell(30,7,'Scadenza',1,0,'L');
$this->Cell(50,7,'Causale',1,0,'L');
$this->Cell(110,7,'Descrizione',1,0,'L');
$this->ln(7);
}
}
//Create new pdf file
$pdf=new FPDF();
//Add first page
$pdf->AddPage();
$pdf = new PDF();
$pdf->AddPage();
$pdf->SetFont('Arial','',10);
$query=mysqli_query($conn, $strSql);
while($row=mysqli_fetch_array($query))
{
$dataScad = $row['DataScadenza1'];
$caus = $row['Causale'];
$desc = $row['Descrizione'];
$pdf->cell(30,7,$dataScad,0,'L');
$pdf->cell(50,7,$caus,0,'L');
$pdf->multicell(110,7,$desc,0,'L');
$pdf->ln(7);
}
$pdf->Output();