codice:
<?php
define('FPDF_FONTPATH','../../t4/FPDF/font/');
require('../../t4/FPDF/fpdf.php');
include ('../../t4/include/connect.php');
include ('../../t4/include/select.php');
// eseguire query prelevare dati
$id=$_REQUEST['id'];
$giorni=mysql_query("SELECT giorni.id, giorni.giorno, giorni.crono, giorni.trasferta, autisti.nome, trattore.targa FROM giorni, autisti, trattore WHERE giorni.id='$id' and giorni.id_autista=autisti.id and giorni.id_trattore=trattore.id order by id desc limit 1") or die (mysql_error());
$movimenti=mysql_query("SELECT movimenti.id, movimenti.ora, movimenti.luogo, movimenti.km, movimenti.evento, movimenti.gasolio, movimenti.adblue, movimenti.note, movimenti.id_sr, movimenti.data, semirimorchio.targa from movimenti, semirimorchio where movimenti.id_sr=semirimorchio.id and movimenti.data=('$data') and movimenti.g_id=('$id') order by movimenti.ora") or die(mysql_error());
while($row=mysql_fetch_array($giorni))
{
$data=$row[giorno];
$crono=$row[crono];
$row=select_trasferta($row);
$trasferta=$row[trasferta];
$autista=$row[nome];
$tr=$row[targa];
}
class PDF extends FPDF
{
/*function Header()
{
//Select Arial bold 15
$this->SetFont('Arial','B',12);
// Titolo Pagina
$this->Cell(3,1,'Giornaliero',1,0,'L');
//Line break
$this->Ln(2);
}*/
function Footer()
{
//1.5 cm dal fondo pagina
$this->SetY(-07);
//Arial italic 8
$this->SetFont('Arial','I',8);
//Numero Pagina
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
$pdf=new PDF('P','cm','A4'); // cm centimentri 1 punto -> 2.54 cm
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','B',12); // I italico U sottolineato
/*$pdf->Cell(1);*/ // sposta la cella a dx
$pdf->Cell(2,1,'Ditta',0,0,L,false); // larghezza, altezza, testo, bordi, a capo automatico, allineamento, trasparenza
$pdf->Ln(1.5);
$pdf->Cell(1.5,1,'Autista',0,0,L,false);
$pdf->Cell(0.7);
$pdf->Cell(3,1,$autista,1,0,L,false);
$pdf->Cell(1.5);
$pdf->Cell(2,1,'Motrice',0,0,L,false);
$pdf->Cell(1);
$pdf->Cell(2,1,$tr,1,0,L,false);
$pdf->Ln(1.5);
$pdf->Cell(1.2,1,'Giorno',0,0,L,false);
$pdf->Cell(1);
$pdf->Cell(2.5,1,$data,1,0,L,false);
$pdf->Ln(1.5);
$pdf->Cell(1,1,'crono',0,0,L,false);
$pdf->Cell(1.2);
$pdf->Cell(2.5,1,$crono,1,0,L,false);
$pdf->Ln(1.5);
$pdf->Cell(1,1,'KM',0,0,L,false);
$pdf->Cell(1.2);
$pdf->Cell(2,1,'123',1,0,L,false);
$pdf->Ln(1.5);
$pdf->Cell(2,1,'Trasferta',0,0,L,false);
$pdf->Cell(0.2);
$pdf->Cell(2.6,1,$trasferta,1,0,L,false);
$pdf->Ln(1.5);
$pdf->Cell(2,1,'Ora',1,0,C,false);
$pdf->Cell(3,1,'Luogo',1,0,C,false);
$pdf->Cell(2,1,'Km',1,0,C,false);
$pdf->Cell(3,1,'Evento',1,0,C,false);
$pdf->Cell(2,1,'Gasolio',1,0,C,false);
$pdf->Cell(2,1,'AdBlue',1,0,C,false);
$pdf->Cell(5.5,1,'Note',1,0,C,false);
$pdf->Ln();
while($mov=mysql_fetch_array($movimenti))
{
$pdf->Cell(2,1,$mov[ora],1,0,L,false);
$pdf->Cell(3,1,$mov[luogo],1,0,L,false);
$pdf->Cell(2,1,$mov[km],1,0,L,false);
$pdf->Cell(3,1,$mov[evento],1,0,L,false);
$pdf->Cell(2,1,$mov[gasolio],1,0,L,false);
$pdf->Cell(2,1,$mov[adblue],1,0,L,false);
$pdf->Cell(5.5,1,$mov[note],1,0,L,false);
$pdf->Ln();
}
$pdf->Output();
?>
io credo che il problema sia il ciclo while all'interno della creazione del pdf solo che non so come fare.. devo metterlo in una funzione esterna e poi chiamare la funzione durante la creazione del ciclo while?