Foros del Web » Programando para Internet » PHP »

FPDF y PHP, creacion de tabla

Estas en el tema de FPDF y PHP, creacion de tabla en el foro de PHP en Foros del Web. Hola que tal, soy totalmente nuevo en este foro y la verdad también en este tema, hago el intento de aprender solo pero en esta ...
  #1 (permalink)  
Antiguo 21/11/2013, 12:26
 
Fecha de Ingreso: noviembre-2013
Mensajes: 13
Antigüedad: 10 años, 5 meses
Puntos: 0
FPDF y PHP, creacion de tabla

Hola que tal, soy totalmente nuevo en este foro y la verdad también en este tema, hago el intento de aprender solo pero en esta ocación no lo logre asi que acudo a ustedes los que saben mas que yo.

El caso es que quiero mandar una tabla que contiene datos de una base de datos a un pdf, estoy usando FPDF pero resulta que cuando mando la variable me pone UNDIFINE



Este es parte de mi código espero y me ayuden

Código PHP:
Ver original
  1. <?php
  2. require ('../Scripts/fpdf/fpdf.php');
  3. require_once('../Connections/conexion.php');
  4.  
  5. $domingo_mp_tlx = "0";
  6. if (isset($_GET["domingo"])) {
  7.   $domingo_mp_tlx = $_GET["domingo"];
  8. }
  9. mysql_select_db($database_conexion, $conexion);
  10. $query_mp_tlx = sprintf("SELECT * FROM asistencia_minuta WHERE asistencia_minuta.fecha = 'domingo'  AND asistencia_minuta.iglesias_nombre_iglesia='NUMERO 1'", GetSQLValueString($domingo_mp_tlx, "text"));
  11. $mp_tlx = mysql_query($query_mp_tlx, $conexion) or die(mysql_error());
  12. $row_mp_tlx = mysql_fetch_array($mp_tlx);
  13. $totalRows_mp_tlx = mysql_num_rows($mp_tlx);
  14.  
  15.  
  16.  
  17. class PDF extends FPDF{
  18. public function Header(){
  19.         $this->Image('../images/elrio_banner.JPG');
  20.         $this-> SetFont ('Arial','B',18);
  21.         $this->Ln(5);
  22.         $this->SetTextColor(0,0,139);
  23.         $this->Cell(190,10,'TOTAL '.$_GET["domingo"],0,0,'C');
  24.         /*$this-> Cell(190,10,'PIE DE PAGINA',0,0,'C');*/
  25.         $this-> Ln(10);
  26.         }
  27.  
  28.     //Tabla coloreada
  29. function TablaColores($header)
  30. {
  31.    
  32. //Colores, ancho de línea y fuente en negrita
  33.     $this->SetFillColor(25,25,112);
  34.     $this->SetTextColor(255);
  35.     $this->SetDrawColor(0,0,0);
  36.     $this->SetLineWidth(.3);
  37.     $this->SetFont('Arial','B',14);
  38. //Cabecera
  39. $fila = mysql_fetch_array($historial);
  40.     for($i=0;$i<count($header);$i++)
  41.     $this->Cell(45,7,$header[$i],1,0,'C',1);
  42.     $this->Ln();
  43.     //Restauración de colores y fuentes
  44.     $this->SetFillColor(224,235,255);
  45.     $this->SetTextColor(0,0,0);
  46.     $this->SetFont('Courier','',12);
  47.     //Datos
  48.        $fill=false;
  49.     $this->Cell(45,6,"Adultos",'LR',0,'L',$fill);
  50.    
  51.     $this->Cell(45,6,''.$row_mp_tlx['num_adultos'],'LR',0,'C',$fill);
  52.     $this->Cell(45,6,"Adultos",'LR',0,'L',$fill);
  53.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  54.     $this->Ln();
  55.           $fill=!$fill;
  56.     $this->Cell(45,6,"Niños",'LR',0,'L',$fill);
  57.     $this->Cell(45,6,"".$row_mp_tlx['num_ninios'],'LR',0,'C',$fill);
  58.     $this->Cell(45,6,"Niños",'LR',0,'L',$fill);
  59.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  60.     $fill=true;
  61.     $this->Ln();
  62.           $fill=!$fill;
  63.     $this->Cell(45,6,"Visitas",'LR',0,'L',$fill);
  64.     $this->Cell(45,6,"".$row_mp_tlx['num_visitas'],'LR',0,'C',$fill);
  65.     $this->Cell(45,6,"Visitas",'LR',0,'L',$fill);
  66.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  67.     $fill=false;
  68.     $this->Ln();
  69.           $fill=!$fill;
  70.     $this->Cell(45,6,"Total",'LR',0,'L',$fill);
  71.     $this->Cell(45,6,"".$row_mp_tlx['total'],'LR',0,'C',$fill);
  72.     $this->Cell(45,6,"Total",'LR',0,'L',$fill);
  73.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  74.     $fill=true;
  75.        $this->Ln();
  76.        $this->Cell(180,0,'','T');
  77. }
  78.  
  79. function TablaColores1($header1)
  80. {
  81. //Colores, ancho de línea y fuente en negrita
  82.     $this->SetFillColor(25,25,112);
  83.     $this->SetTextColor(255);
  84.     $this->SetDrawColor(0,0,0);
  85.     $this->SetLineWidth(.3);
  86.     $this->SetFont('Arial','B',14);
  87. //Cabecera
  88.  
  89.     for($i=0;$i<count($header1);$i++)
  90.     $this->Cell(45,7,$header1[$i],1,0,'C',1);
  91.     $this->Ln();
  92.     //Restauración de colores y fuentes
  93.     $this->SetFillColor(224,235,255);
  94.     $this->SetTextColor(0,0,0);
  95.     $this->SetFont('Courier','',12);
  96.     //Datos
  97.        $fill=false;
  98.     $this->Cell(45,6,"Adultos",'LR',0,'L',$fill);
  99.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  100.     $this->Cell(45,6,"Adultos",'LR',0,'L',$fill);
  101.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  102.     $this->Ln();
  103.           $fill=!$fill;
  104.     $this->Cell(45,6,"Niños",'LR',0,'L',$fill);
  105.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  106.     $this->Cell(45,6,"Niños",'LR',0,'L',$fill);
  107.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  108.     $fill=true;
  109.     $this->Ln();
  110.           $fill=!$fill;
  111.     $this->Cell(45,6,"Visitas",'LR',0,'L',$fill);
  112.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  113.     $this->Cell(45,6,"Visitas",'LR',0,'L',$fill);
  114.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  115.     $fill=false;
  116.     $this->Ln();
  117.           $fill=!$fill;
  118.     $this->Cell(45,6,"Total",'LR',0,'L',$fill);
  119.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  120.     $this->Cell(45,6,"Total",'LR',0,'L',$fill);
  121.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  122.     $fill=true;
  123.        $this->Ln();
  124.        $this->Cell(180,0,'','T');
  125. }
  126.  
  127.   function TablaColores2($header2)
  128. {
  129. //Colores, ancho de línea y fuente en negrita
  130.     $this->SetFillColor(25,25,112);
  131.     $this->SetTextColor(255);
  132.     $this->SetDrawColor(0,0,0);
  133.     $this->SetLineWidth(.3);
  134.     $this->SetFont('Arial','B',14);
  135. //Cabecera
  136.  
  137.     for($i=0;$i<count($header2);$i++)
  138.     $this->Cell(45,7,$header2[$i],1,0,'C',1);
  139.     $this->Ln();
  140.     //Restauración de colores y fuentes
  141.     $this->SetFillColor(224,235,255);
  142.     $this->SetTextColor(0,0,0);
  143.     $this->SetFont('Courier','',12);
  144.     //Datos
  145.        $fill=false;
  146.     $this->Cell(45,6,"Adultos",'LR',0,'L',$fill);
  147.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  148.     $this->Cell(45,6,"Adultos",'LR',0,'L',$fill);
  149.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  150.     $this->Ln();
  151.           $fill=!$fill;
  152.     $this->Cell(45,6,"Niños",'LR',0,'L',$fill);
  153.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  154.     $this->Cell(45,6,"Niños",'LR',0,'L',$fill);
  155.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  156.     $fill=true;
  157.     $this->Ln();
  158.           $fill=!$fill;
  159.     $this->Cell(45,6,"Visitas",'LR',0,'L',$fill);
  160.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  161.     $this->Cell(45,6,"Visitas",'LR',0,'L',$fill);
  162.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  163.     $fill=false;
  164.     $this->Ln();
  165.           $fill=!$fill;
  166.     $this->Cell(45,6,"Total",'LR',0,'L',$fill);
  167.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  168.     $this->Cell(45,6,"Total",'LR',0,'L',$fill);
  169.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  170.     $fill=true;
  171.        $this->Ln();
  172.        $this->Cell(180,0,'','T');
  173. }
  174.  
  175. function TablaColores3($header3)
  176. {
  177. //Colores, ancho de línea y fuente en negrita
  178.     $this->SetFillColor(25,25,112);
  179.     $this->SetTextColor(255);
  180.     $this->SetDrawColor(0,0,0);
  181.     $this->SetLineWidth(.3);
  182.     $this->SetFont('Arial','B',14);
  183. //Cabecera
  184.  
  185.     for($i=0;$i<count($header3);$i++)
  186.     $this->Cell(45,7,$header3[$i],1,0,'C',1);
  187.     $this->Ln();
  188.     //Restauración de colores y fuentes
  189.     $this->SetFillColor(224,235,255);
  190.     $this->SetTextColor(0,0,0);
  191.     $this->SetFont('Courier','',12);
  192.     //Datos
  193.        $fill=false;
  194.     $this->Cell(45,6,"Adultos",'LR',0,'L',$fill);
  195.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  196.     $this->Cell(45,6,"Adultos",'LR',0,'L',$fill);
  197.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  198.     $this->Ln();
  199.           $fill=!$fill;
  200.     $this->Cell(45,6,"Niños",'LR',0,'L',$fill);
  201.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  202.     $this->Cell(45,6,"Niños",'LR',0,'L',$fill);
  203.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  204.     $fill=true;
  205.     $this->Ln();
  206.           $fill=!$fill;
  207.     $this->Cell(45,6,"Visitas",'LR',0,'L',$fill);
  208.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  209.     $this->Cell(45,6,"Visitas",'LR',0,'L',$fill);
  210.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  211.     $fill=false;
  212.     $this->Ln();
  213.           $fill=!$fill;
  214.     $this->Cell(45,6,"Total",'LR',0,'L',$fill);
  215.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  216.     $this->Cell(45,6,"Total",'LR',0,'L',$fill);
  217.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  218.     $fill=true;
  219.        $this->Ln();
  220.        $this->Cell(180,0,'','T');
  221. }
  222.  
  223.  
  224. function TablaColores4($header4)
  225. {
  226. //Colores, ancho de línea y fuente en negrita
  227.     $this->SetFillColor(25,25,112);
  228.     $this->SetTextColor(255);
  229.     $this->SetDrawColor(0,0,0);
  230.     $this->SetLineWidth(.3);
  231.     $this->SetFont('Arial','B',14);
  232. //Cabecera
  233.  
  234.     for($i=0;$i<count($header4);$i++)
  235.     $this->Cell(45,7,$header4[$i],1,0,'C',1);
  236.     $this->Ln();
  237.     //Restauración de colores y fuentes
  238.     $this->SetFillColor(224,235,255);
  239.     $this->SetTextColor(0,0,0);
  240.     $this->SetFont('Courier','',12);
  241.     //Datos
  242.        $fill=false;
  243.     $this->Cell(45,6,"Adultos",'LR',0,'L',$fill);
  244.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  245.    
  246.     $this->Ln();
  247.           $fill=!$fill;
  248.     $this->Cell(45,6,"Niños",'LR',0,'L',$fill);
  249.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  250.    
  251.     $fill=true;
  252.     $this->Ln();
  253.           $fill=!$fill;
  254.     $this->Cell(45,6,"Visitas",'LR',0,'L',$fill);
  255.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  256.    
  257.     $fill=false;
  258.     $this->Ln();
  259.           $fill=!$fill;
  260.     $this->Cell(45,6,"Total",'LR',0,'L',$fill);
  261.     $this->Cell(45,6,"",'LR',0,'C',$fill);
  262.    
  263.     $fill=true;
  264.        $this->Ln();
  265.        $this->Cell(90,0,'','T');
  266. }
  267.  
  268. }
  269.  
  270. $pdf = new PDF ();
  271. $pdf-> AddPage();
  272.  
  273.  
  274.  
  275. //Títulos de las columnas
  276. $pdf->SetFont('Arial','B',18);
  277. $pdf->SetTextColor(255,255,0);
  278.  
  279. $header=array('Río Tlaxcala','Número','Río Apizaco','Número');
  280. $header1=array('Río Calpulalpan','Número','Río Huamantla','Número');
  281. $header2=array('Río México','Número','Río Chiautempan','Número');
  282. $header3=array('Río Teolocholco','Número','Río A. Centro','Número');
  283. $header4=array('Río Zacarlan','Número');
  284.  
  285. $pdf->AliasNbPages();
  286. //Primera página
  287.  
  288. $pdf->SetY(50);
  289. //$pdf->AddPage();
  290. $pdf->TablaColores($header);
  291. $pdf->Ln(10);
  292. $pdf->TablaColores1($header1);
  293. $pdf->Ln(10);
  294. $pdf->TablaColores2($header2);
  295. $pdf->Ln(10);
  296. $pdf->TablaColores3($header3);
  297. $pdf->Ln(10);
  298. $pdf->TablaColores4($header4);
  299.  
  300.  
  301. $pdf->Output();
  302.  
  303. ?>

Etiquetas: fpdf
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 02:37.