codice:
<?php
define('FPDF_FONTPATH','font/');
require('fpdf.php');
//Connect to your database
//include("config.inc.php");
//include("connect.inc.php");
$db_host = "localhost";
$db_user = "***";
$db_password = "***";
$db_name = "***";
$db = mysql_connect($db_host, $db_user, $db_password);
if ($db == FALSE)
die ("Errore nella connessione. Verificare i parametri nel file config.inc.php" . mysql_error( ) );
mysql_select_db($db_name, $db)
or die ("Errore nella selezione del database. Verificare i parametri nel file config.inc.php" . mysql_error( ) );
//Create new pdf file
$pdf=new FPDF();
//Open file
$pdf->Open();
//Disable automatic page break
$pdf->SetAutoPageBreak(false);
//Add first page
$pdf->AddPage();
//set initial y axis position per page
$y_axis_initial = 25;
//print column titles for the actual page
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',12);
$pdf->SetY($y_axis_initial);
$pdf->SetX(25);
$pdf->Cell(30,6,'titolo',1,0,'L',1);
$pdf->Cell(30,6,'regione',1,0,'L',1);
$pdf->Cell(30,6,'tipopiatto',1,0,'L',1);
$pdf->Cell(30,6,'persone',1,0,'L',1);
$pdf->Cell(30,6,'ingredienti',1,0,'L',1);
$pdf->Cell(30,6,'preparazione',1,0,'L',1);
$pdf->Cell(30,6,'note',1,0,'L',1);
$pdf->Cell(30,6,'difficolta',1,0,'L',1);
$y_axis = $y_axis + $row_height;
//Select the Products you want to show in your PDF file
$result=mysql_query("SELECT titolo, regione, tipopiatto, persone, ingredienti, preparazione, note, difficolta FROM ricette WHERE id='$id'");
//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(25);
$pdf->Cell(30,6,'titolo',1,0,'L',1);
$pdf->Cell(30,6,'regione',1,0,'L',1);
$pdf->Cell(30,6,'tipopiatto',1,0,'L',1);
$pdf->Cell(30,6,'persone',1,0,'L',1);
$pdf->Cell(30,6,'ingredienti',1,0,'L',1);
$pdf->Cell(30,6,'preparazione',1,0,'L',1);
$pdf->Cell(30,6,'note',1,0,'L',1);
$pdf->Cell(30,6,'difficolta',1,0,'L',1);
//Go to next row
$y_axis = $y_axis + $row_height;
//Set $i variable to 0 (first row)
$i = 0;
}
$titolo = $row['titolo'];
$regione = $row['regione'];
$tipopiatto = $row['tipopiatto'];
$persone = $row['persone'];
$ingredienti = $row['ingredienti'];
$preparazione = $row['preparazione'];
$note = $row['note'];
$difficolta = $row['difficolta'];
$pdf->SetY($y_axis);
$pdf->SetX(25);
$pdf->Cell(30,6,$titolo,1,0,'L',1);
$pdf->Cell(30,6,$regione,1,0,'L',1);
$pdf->Cell(30,6,$tipopiatto,1,0,'L',1);
$pdf->Cell(30,6,$persone,1,0,'L',1);
$pdf->Cell(30,6,$ingredienti,1,0,'L',1);
$pdf->Cell(30,6,$preparazione,1,0,'L',1);
$pdf->Cell(30,6,$note,1,0,'L',1);
$pdf->Cell(30,6,$difficolta,1,0,'L',1);
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
}
mysql_close($link);
//Create file
$pdf->Output();
?>
che mi crea 2 problemi.