he copiado el codigo tal cual pero he hecho algunos cambios para adaptarlo a mi BD y a mis campos. el codigo es el siguiente:
Código PHP:
<?php
require("../../aut_verifica.inc.php");
error_reporting(E_ALL);
define('FPDF_FONTPATH','../funcions/font/');
include('../funcions/fpdf.php');
class PDF extends FPDF
{
function PDF($orientation='l',$unit='mm',$format='A4')
{
//Llama al constructor de la clase padre
$this->FPDF($orientation,$unit,$format);
//Iniciacin de variables
$this->B=0;
$this->I=0;
$this->U=0;
}
function Header()
{
//Logo
//$this->Image('../imagenes/logo.png',5,8,33);
//Arial bold 15
$this->SetFont('Arial','B',15);
//Movernos a la derecha
$this->Cell(80);
//T tulo
$this->Cell(80,10,'Detalle de la tabla tbl_pruebas',1,0,'C');
//Salto de línea
$this->Ln(15);
}
//Pie de página
function Footer()
{
//Posicin: a 1,5 cm del final
$this->SetY(-15);
//Arial italic 8
$this->SetFont('Arial','I',8);
//Número de pgina
$this->Cell(0,10,'Pagina '.$this->PageNo().'/{nb}',0,0,'C');
}
//colorear la tabla y cargar datos
function FancyTable($header,$data)
{
//Colores, ancho de línea y fuente en negrita
$this->SetFillColor(255,0,0);
$this->SetTextColor(255);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.3);
$this->SetFont('','B');
//Cabecera
$w=array(20,20,20,20,20,160);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C',1);
$this->Ln();
//Restauración de colores y fuentes
$this->SetFillColor(224,235,255);
$this->SetTextColor(0);
$this->SetFont('');
//Datos
$fill=0;
/*******************************************************************************************/
//var per montar la clausula where segons els parametres
$WHEREHAN='';
//var per pasar les dades per la url
$ur='';
function FWhere($w) {
return ($w == '') ? ' WHERE ' : "$w AND ";
}
/*******************************************************************************************/
//Recollim les variables del Formulari de busqueda
if (isset($_GET['id_localitat']) && ($_GET['id_localitat'] != 0)) {
$WHEREHAN = Fwhere($WHEREHAN) . " id_localitat = $_GET[id_localitat]";
}
if (isset($_GET['id_seccio']) && ($_GET['id_seccio'] != 0)) {
$WHEREHAN = Fwhere($WHEREHAN) . " id_seccio = $_GET[id_seccio]";
}
if (isset($_GET['ref_activitat']) && ($_GET['ref_activitat'] != '')) {
$WHEREHAN = Fwhere($WHEREHAN) . " ref_averia LIKE '$_GET[ref_activitat]%'";
}
if (isset($_GET['id_maquina']) && ($_GET['id_maquina'] != 0)) {
$WHEREHAN = Fwhere($WHEREHAN) . " id_maquina LIKE '$_GET[id_maquina]%'";
}
if (isset($_GET['data_desde']) && ($_GET['data_desde'] != '')) {
$data_desde=giradata($_GET[data_desde]);
$WHEREHAN = Fwhere($WHEREHAN) . " data_avis >= '$data_desde'";
}
if (isset($_GET['data_fins']) && ($_GET['data_fins'] != '')){
$data_fins=giradata($_GET[data_fins]);
$WHEREHAN = Fwhere($WHEREHAN) . " data_avis <= '$data_fins'";
}
if (isset($_GET['prioritat']) && ($_GET['prioritat'] != 0)) {
$WHEREHAN = Fwhere($WHEREHAN) . " prioritat = '$_POST[prioritat]'";
}
if (isset($_GET['tipus_maquina']) && ($_GET['tipus_maquina'] != 0)) {
$WHEREHAN = Fwhere($WHEREHAN) . " tipus_maq = '$_GET[tipus_maquina]'";
}
$Sql = "SELECT id_activitat, ref_activitat, id_maquina, id_localitat,
id_seccio, data_avis, descripcio
FROM activitats $WHEREHAN ORDER BY data_avis DESC
LIMIT 0,100";
$Query = mysql_query($Sql);
//Bucle para generar los datos
while($row = mysql_fetch_row($Query))
{
//$this->Cell($w[0],6,$row['1'],'LR',0,'C',$fill);
$this->Cell($w[1],6,$row['1'],'LR',0,'C',$fill);
$this->Cell($w[2],6,$row['2'],'LR',0,'C',$fill);
$this->Cell($w[3],6,$row['3'],'LR',0,'C',$fill);
$this->Cell($w[4],6,$row['4'],'LR',0,'C',$fill);
$this->Cell($w[5],6,$row['5'],'LR',0,'C',$fill);
$this->Cell($w[6],6,$row['6'],'LR',0,'L',$fill);
$this->Ln();
$fill=!$fill;
//contador de línea para establecer líneas por página y cabecera
$cuenta =0;
if($cuenta == 25)
{
$this->Cell(array_sum($w),0,'','T');
$this->Ln();
$this->AddPage();
$this->SetFillColor(255,0,0);
$this->SetTextColor(255);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.3);
$this->SetFont('','B');
//Cabecera
$w=array(20,20,20,20,20,160);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C',1);
$this->Ln();
$cuenta = 0;
//Restauración de colores y fuentes
$this->SetFillColor(224,235,255);
$this->SetTextColor(0);
$this->SetFont('');
}
}
$this->Cell(array_sum($w),0,'','T');
}
}
//==============================================================
//Iniciar documento PDF
$pdf=new PDF();
$pdf->AliasNbPages();
//Titulos de las columnas
$header=array('Ref.Averia','Maquina','Localidd','Seccion','Fecha','Descripcion');
$pdf->SetFont('Arial','',10);
$pdf->AddPage();
$pdf->FancyTable($header,$data);
$pdf->Output();
donde se declara Data? donde se le asignan los valore s data? no he sido capaz de verlo/encontrarlo...
este ya estoy al caso... a ver si areglando el 1ero se arregla el segundo... q es lo mas posible!