Codice PHP:
<?php
define('FPDF_FONTPATH','font/');
include ("../config.inc.php");
require('classe_voti2.php');
class PDF extends PDF_classe1
{
function Header()
{
$this->SetFont('Arial','B',18);
//sfondo titolo
$this->Ln();
$this->SetFillColor(255,200,0);
$this->SetX(85);
//Titolo
$this->Cell(50,6,'TITOLO',1,1,'C',1);
//spazio fra titolo e tabella
$this->Ln(15);
}
}
$pdf=new PDF();
$pdf->Open();
$pdf->AddPage();
$pdf->Table('SELECT * FROM iscritti, liste
INNER JOIN affluenza ON affluenza.sez=iscritti.sez
INNER JOIN voti_lista ON voti_lista.sez=iscritti.sez
WHERE voti_lista.sez<10');
$pdf->Output();
?>
file classe_voti2.php
Codice PHP:
<?php
require('../fpdf153/fpdf.php');
class PDF_classe1 extends FPDF
{
function Header()
{
//Stampa la testata della tabella se necessario
if($this->ProcessingTable)
$this->TableHeader();
}
function TableHeader()
{
}
function Row($data)
{
$totaleiscritti = $data[isc_mas]+$data[isc_fem];
$totaleriga2 = number_format($totaleriga,',','.','.');
$percmas=$data[vot_mas]/$totaleriga*100;
$percmas=number_format($percmas,2,',','.');
$totalevotanti = $data[vot_mas]+$data[vot_fem];
$percfem=$data[vot_fem]/$totaleriga*100;
$percfem=number_format($percfem,2,',','.');
$this->SetFillColor(232,232,232);
$this->SetFont('Arial','',12);
$this->SetY(30);
$this->SetX(135);
$this->Cell(50,6,'Sezione Num.',1,0,'R',0);
$this->Cell(20,6,' '.$data[sez],1,0,'L',0);
//inizio stampa iscritti
$this->SetY(50);
$this->SetX(5);
$this->Cell(40,6,'Iscritti Maschi',1,0,'L',0);
$this->Cell(20,6,$data[isc_mas],1,0,'R',0);
$this->SetY(58);
$this->SetX(5);
$this->Cell(40,6,'Iscritti Femmine',1,0,'L',0);
$this->Cell(20,6,$data[isc_fem],1,0,'R',0);
$this->SetY(66);
$this->SetX(5);
$this->Cell(40,6,'Totale Iscritti',1,0,'L',0);
$this->Cell(20,6,$totaleiscritti,1,0,'R',0);
//fine stampa iscritti
//inizio stampa votanti
$this->SetY(50);
$this->SetX(75);
$this->Cell(40,6,'Votanti Maschi',1,0,'L',0);
$this->Cell(20,6,$data[vot_mas],1,0,'R',0);
$this->SetY(58);
$this->SetX(75);
$this->Cell(40,6,'Votanti Femmine',1,0,'L',0);
$this->Cell(20,6,$data[vot_fem],1,0,'R',0);
$this->SetY(66);
$this->SetX(75);
$this->Cell(40,6,'Totale Votanti',1,0,'L',0);
$this->Cell(20,6,$totalevotanti,1,0,'R',0);
//fine stampa votanti
}
function Table($query)
{
//errore query
$res=mysql_query($query) or die('Error: '.mysql_error()."
Query: $query");
while($row=mysql_fetch_assoc($res))
$this->Row($row);
}
}
?>
Il problema è che se stampo una sola sez totto OK.