Código PHP:
<td><a href="reporte_vuelo.php?id=<?php echo $vuelos['vue_cod']?>"><img src="imagenes/pdf.png" title="Exporte a PDF" /></a></td>
Codigo de Reporte_vuelo.php
Código PHP:
<?php
// incluimos la libreria fpdf
require('clases/fpdf/fpdf.php');
// incluimos la conexion a la base de datos
require('clases/conexiones.class.php');
class PDF extends FPDF
{
var $widths;
var $aligns;
function SetWidths($w)
{
$this->widths=$w;
}
function SetAligns($a)
{
$this->aligns=$a;
}
function Row($data)
{
$nb=0;
for($i=0;$i<count($data);$i++)
$nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
$h=4*$nb;
$this->CheckPageBreak($h);
for($i=0;$i<count($data);$i++)
{
$w=$this->widths[$i];
$a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
$x=$this->GetX();
$y=$this->GetY();
$this->Rect($x,$y,$w,$h);
$this->MultiCell($w,4,$data[$i],0,$a);
$this->SetXY($x+$w,$y);
}
$this->Ln($h);
}
function CheckPageBreak($h)
{
if($this->GetY()+$h>$this->PageBreakTrigger)
$this->AddPage($this->CurOrientation);
}
function NbLines($w,$txt)
{
$cw=&$this->CurrentFont['cw'];
if($w==0)
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
$s=str_replace("\r",'',$txt);
$nb=strlen($s);
if($nb>0 and $s[$nb-1]=="\n")
$nb--;
$sep=-1;
$i=0;
$j=0;
$l=0;
$nl=1;
while($i<$nb)
{
$c=$s[$i];
if($c=="\n")
{
$i++;
$sep=-1;
$j=$i;
$l=0;
$nl++;
continue;
}
if($c==' ')
$sep=$i;
$l+=$cw[$c];
if($l>$wmax)
{
if($sep==-1)
{
if($i==$j)
$i++;
}
else
$i=$sep+1;
$sep=-1;
$j=$i;
$l=0;
$nl++;
}
else
$i++;
}
return $nl;
}
function Header()
{
$this->SetFont('Arial','',16);
$this->Text(65,14,' REPORTE DE VUELO ',0,'C', 0);
$this->Ln(20);
}
function Footer()
{
$this->SetY(-15);
$this->SetFont('Arial','B',8);
$this->Image('imagenes/logo.png',20,8,39);
$this->Cell(100,10,'Reporte vuelo',0,0,'L');
}
}
$vuelos=$_GET['id'];
// creamos el objeto FPDF
$pdf=new PDF('L','mm','Letter'); // vertical, milimetros y tamaño
$pdf->Open();
$pdf->AddPage(); // agregamos la pagina
$pdf->SetMargins(20,20,20); // definimos los margenes en este caso estan en milimetros
$pdf->Ln(1);
// Realizamos la consulta
$con = new BD;
$vuelos = $con->conectar();
// $vuelos contiene el id del vuelo a consultar
$strConsulta = "SELECT v.vue_cod, p.pil_rut, p.pil_nom, p.pil_ap, p.pil_am, v.vue_fech_sal, v.vue_fech_lleg, av.avi_matric, v.vue_horo_inicio, v.vue_horo_final, v.vue_destino, v.tiempo_vuelo
FROM vuelos AS v
JOIN pilotos AS p ON v.pil_rut = p.pil_rut
JOIN aviones AS av ON v.avi_matric = av.avi_matric
WHERE v.vue_cod='$vuelos'";
$vuelos = mysql_query($strConsulta);
$fila = mysql_fetch_array($vuelos);
// listamos los datos con Cell
$pdf->SetFont('Arial','',12); // definimos el tipo de letra y el tamaño
// Cell esta formado por (posición de inicio, ancho, texto, borde, cambio de linea, posición del texto)
$pdf->Cell(0,6,'Codigo de vuelo: '.$fila['vue_cod'],0,1);
$pdf->Cell(0,6,'Matricula Aeronave: '.$fila['avi_matric'],0,1);
$pdf->Cell(0,6,'RUT piloto: '.$fila['pil_rut'],0,1);
$pdf->Cell(0,6,'Nombre del Piloto: '.$fila['pil_nom'].' '.$fila['pil_ap'].' '.$fila['pil_am'],0,1);
$pdf->Cell(0,6,'Fecha de Salida: '.$fila['vue_fech_sal'],0,1);
$pdf->Cell(0,6,'Fecha de Llegada: '.$fila['vue_fech_lleg'],0,1);
$pdf->Cell(0,6,'Salida a las: '.$fila['vue_horo_inicio'],0,1);
$pdf->Cell(0,6,'Llegada a las: '.$fila['vue_horo_final'],0,1);
$pdf->Cell(0,6,'Con destino a: '.$fila['vue_destino'],0,1);
$pdf->Cell(0,6,'Diferencia Total del Vuelo: '.$fila['tiempo_vuelo'],0,1);
$pdf->Ln(10);
$pdf->Output();
?>
tengo uno con codigo 4 y no lo imprime, puede ser algo minimo pero le he dado mil vueltas y nada, agradesco su ayuda u orientacion