Ver Mensaje Individual
  #8 (permalink)  
Antiguo 31/10/2010, 13:14
Avatar de carlos_belisario
carlos_belisario
Colaborador
 
Fecha de Ingreso: abril-2010
Ubicación: Venezuela Maracay Aragua
Mensajes: 3.156
Antigüedad: 14 años
Puntos: 461
Respuesta: Ayuda con FPDF

prueba esto
Código PHP:
Ver original
  1. <?php
  2. function FancyTable($header,$data)
  3.     {      
  4.         //Colores, ancho de línea y fuente en negrita
  5.         $this->SetFillColor(255);
  6.         $this->SetTextColor(0);
  7.         $this->SetDrawColor(0);
  8.         $this->SetLineWidth(.3);
  9.         $this->SetFont('','B');
  10.         //Cabecera
  11.         $w=array(22,80,10,10,10,10,60);
  12.         for($i=0;$i<count($header);$i++)
  13.         $this->Cell($w[$i],7,$header[$i],1,0,'C',1);
  14.         $this->Ln();
  15.         //Restauración de colores y fuentes
  16.         $this->SetFillColor(255);
  17.         $this->SetTextColor(0);
  18.         $this->SetFont('');
  19.         //Datos
  20.         $fill=false;               
  21.         foreach($data as $row)
  22.         {          
  23.             $this->setFont('Arial','',7);
  24.             $this->Cell($w[0],6,$row['datomostrar'],'LR',0,'L',$fill);#aca colocas los campos que vas a mostrar
  25.             $this->Cell($w[1],6,$row['datomostrar2'],'LR',0,'L',$fill);        
  26.             $this->Ln();
  27.             $fill=!$fill;
  28.         }
  29.         $this->Cell(array_sum($w),0,'','T');
  30.     }
  31. $sql='SELECT * FROM empresa';
  32. $res=mysql_query($sql,Conectar::con());
  33. while($row=mysql_fetch_assoc($res)){
  34.         $data[]=array_merge($row);
  35. }
  36. //Títulos de las columnas
  37. $header=array('ID Empresa','Nombre','Direccion','Telefono');
  38. $pdf->SetFont('Arial','',14);
  39. $pdf->AddPage();
  40. $pdf->FancyTable($header,$data);
  41. $pdf->Output();
  42. ?>
ojo no coloque los includes ni inicie la clase solo te hice la funcion y la consulta, y tu debes colocar los campos que quieres mostrar y el tamaño ya que te coloque una que yo tenia ya
__________________
aprende d tus errores e incrementa tu conocimientos
it's not a bug, it's an undocumented feature By @David
php the right way