Foros del Web » Programando para Internet » PHP »

Nombres de Columnas en FPDF

Estas en el tema de Nombres de Columnas en FPDF en el foro de PHP en Foros del Web. Buenas tardes... Mi problema radica que tengo este codigo para pdf con la libreria FPDF @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código PHP: Ver original <?php   require ( ...
  #1 (permalink)  
Antiguo 11/03/2013, 17:38
 
Fecha de Ingreso: noviembre-2012
Ubicación: Tegucigalpa
Mensajes: 94
Antigüedad: 11 años, 5 meses
Puntos: 0
Nombres de Columnas en FPDF

Buenas tardes...

Mi problema radica que tengo este codigo para pdf con la libreria FPDF

Código PHP:
Ver original
  1. <?php  
  2. require('fpdf.php');  
  3.  
  4. class PDF extends FPDF  
  5. {  
  6.  
  7.  
  8. function Header()
  9.  
  10. {
  11.  
  12.     /*include('Connections/t2.php');*/
  13.  
  14.     $fecha = date("Y-m-d");
  15.  
  16.         $this->Cell(167,23,"  ",0,0,'C');
  17.         $this->Ln(4);
  18.  
  19.     $this->SetFont('Arial','B',13);
  20.  
  21.     $this->Cell(167,23,"REPORTE DE ALUMNOS DE UPI --- FECHA: ".$fecha."  ",0,0,'C');
  22.  
  23.     $this->Ln(4);
  24.  
  25.     $this->SetFont('Arial','',11); 
  26.  
  27.     $this->Cell(167,23,"Reporte General del Listado de Alumnos",0,0,'C');  
  28.  
  29.     $this->Ln(4);
  30.  
  31.     $this->SetFont('Arial','',8);
  32.  
  33.     $this->Ln(14); 
  34.      
  35.  
  36. }
  37.  
  38.  
  39.  
  40. //Load data  
  41. function LoadData($file)  
  42. {  
  43. //Read file lines  
  44. $lines=file($file);  
  45. $data=array();  
  46. foreach($lines as $line)  
  47. $data[]=explode(';',chop($line));  
  48. return $data;  
  49. }  
  50.  
  51.  
  52.  
  53. //Colored table  
  54. function FancyTable($header,$data)  
  55. {  
  56. //Colors, line width and bold font  
  57. $this->SetFillColor(255,0,0);  
  58. $this->SetTextColor(255);  
  59. $this->SetDrawColor(128,0,0);  
  60. $this->SetLineWidth(.3);  
  61. $this->SetFont('','B');  
  62. //Header  
  63. $w=array(25,35,35,25,70,130);  
  64. for($i=0;$i<count($header);$i++)  
  65. $this->Cell($w[$i],7,$header[$i],1,0,'C',true);  
  66. $this->Ln();  
  67. //Color and font restoration  
  68. $this->SetFillColor(224,235,255);  
  69. $this->SetTextColor(0);  
  70. $this->SetFont('');  
  71. //Data  
  72. $fill=false;  
  73. foreach($data as $row)  
  74. {  
  75. $this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);  
  76. $this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);  
  77. $this->Cell($w[2],6,$row[2],'LR',0,'L',$fill);  
  78. $this->Cell($w[3],6,$row[3],'LR',0,'C',$fill);  
  79. $this->Cell($w[4],6,$row[4],'LR',0,'R',$fill);  
  80. $this->Cell($w[5],6,$row[5],'LR',0,'R',$fill);  
  81. $this->Ln();  
  82. $fill=!$fill;  
  83. }  
  84. $this->Cell(array_sum($w),0,'','T');  
  85. }  
  86. }  
  87.  
  88. $pdf=new PDF('L','mm','Legal');  
  89. //Column titles  
  90. $header=array('Cuenta','Nombre','Apellido','Nacimiento','Lugar Nac','Direccion');  
  91. //Data loading  
  92.  
  93. //*** Load MySQL Data ***//  
  94. include("config.php");  
  95. $strSQL = "SELECT * FROM alumno";  
  96. $objQuery = mysql_query($strSQL,$link);  
  97. $resultData = array();  
  98. for ($i=0;$i<mysql_num_rows($objQuery);$i++) {  
  99. $result = mysql_fetch_array($objQuery);  
  100. array_push($resultData,$result);  
  101. }  
  102. //************************//  
  103.  
  104. $pdf->SetFont('Arial','',10);  
  105.  
  106.  
  107. //*** Table 3 ***//  
  108. $pdf->AddPage();  
  109. $pdf->Image('image/upi_peque.gif',80,8,33);  
  110. $pdf->Ln(35);  
  111. $pdf->FancyTable($header,$resultData);
  112.  
  113. $pdf-> $header=array('Cuenta','Nombre','Apellido','Nacimiento','Lugar Nac','Direccion');  
  114.  
  115. $pdf->Output();  
  116. ?>

Lo que quiero es que mi encabezado de la tabla, me salga en todas las nuevas paginas. Osea que este:

Código PHP:
Ver original
  1. $header=array('Cuenta','Nombre','Apellido','Nacimiento','LugarNac','Direccion');

>Porque actualmente me sale corrido los registros y quiero que se visualizen estos nombres al comienzo de cada pagina.


Muchisisimas si pueden ayudarme. Se los agradecere enormemente.
  #2 (permalink)  
Antiguo 11/03/2013, 19:01
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 1 mes
Puntos: 574
Respuesta: Nombres de Columnas en FPDF

Código PHP:
Ver original
  1. $pdf->AddPage();  
  2. $pdf->Image('image/upi_peque.gif',80,8,33);  
  3. $pdf->Ln(35);
  4. //////////Array de encabezados//////////////////
  5. $header=array('Cuenta','Nombre','Apellido','Nacimiento','Lugar Nac','Direccion');  
  6. ////////////////////////////////////////////////////////
  7. $pdf->FancyTable($header,$resultData);
__________________
Quim
--------------------------------------------------
Ayudar a ayudar es una buena práctica!!! Y da buenos resultados.

Etiquetas: columnas, fpdf, mysql, nombres, registro, select, sql, tabla
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:31.