Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] variables fpdf en php y mysql

Estas en el tema de variables fpdf en php y mysql en el foro de PHP en Foros del Web. Buenos días. Estoy trabajando con las librerías del fdpf para php, elaborando unas tablas con datos extraídos de una consulta sql, pero la parecer algo ...
  #1 (permalink)  
Antiguo 26/03/2014, 06:30
Avatar de letingel  
Fecha de Ingreso: noviembre-2013
Ubicación: neiva
Mensajes: 41
Antigüedad: 10 años, 5 meses
Puntos: 0
Pregunta variables fpdf en php y mysql

Buenos días.

Estoy trabajando con las librerías del fdpf para php, elaborando unas tablas con datos extraídos de una consulta sql, pero la parecer algo no estoy haciendo bien ya que no me imprime los datos dentro de las celdas, ya probe y por fuera si imprime.

Si alguien tiene alguna sugerencia lo agradezco.

Aqui el link para ver el pdf

http://www.ctrlobra.letingel.com/usu....php?id_item=1

Aqui el codigo:

Código PHP:
<?php
include('../../conexion.php');
include(
'fpdf/fpdf.php');
//Variables para consulta
$id_salidas $_GET['id_item'];
//Consulta sql encabezado
$query1 mysql_query("SELECT * FROM salida_ingreso WHERE id_salida_ingreso = '$id_salidas'");
$encabezado mysql_fetch_array($query1);
//Consulta para cuerpo tabla
$query2 mysql_query("SELECT * FROM items_2 WHERE id_acta = '$id_salidas'");
$cuerpo mysql_fetch_array($query2);
//Variables para celdas
   
$destino $encabezado['destino'];
   
$tipo $encabezado['tipo_solicitud'];
   
$fecha $encabezado['fecha2'];
   
$id $encabezado['id_salida_ingreso'];
header("Content-Type: text/html; charset=iso-8859-1 ");
class 
PDF extends FPDF
{
   
//Columna actual
   
var $col=0;
   
//Ordenada de comienzo de la columna
   
var $y=0;
   
//Cabecera de página
function Header()
{
//Logo
$this->Image("images/logo.jpg",12,11,35,19,"JPG");
//Arial bold 15
$this->SetFont('Arial','',12);
//Encabezado
$this->Cell(40,20,'',1,0,'r');
$this->Cell(80,10,'Sistema Integrado de Gestion',1,0,'C');
$this->Cell(30,5,'Vigencia',1,0,'C');
$this->Cell(40,5,'Mayo 1 de 2013',1,0,'C');
$this->Ln(5);
$this->Cell(120);
$this->Cell(30,5,'Pagina',1,0,'C');
$this->Cell(40,5,'1 de 1',1,0,'C');
$this->Ln(5);
$this->Cell(40);
$this->Cell(80,10,'Salida e ingreso de almacen',1,0,'C');
$this->Cell(30,5,'Codigo',1,0,'C');
$this->Cell(40,5,'GANA-RE-002',1,0,'C');
$this->Ln(5);
$this->Cell(120);
$this->Cell(30,5,'Version',1,0,'C');
$this->Cell(40,5,'001',1,0,'C');
//Contenido del formulario
$this->Ln(8);
$this->SetFont('Arial','',12);
$this->SetFillColor(200,220,255);
$this->Cell(25,5,'Uso/destino:',0,0,'C');
$this->Cell(50,5,$destino,1,0,'C');
$this->Cell(8,5,'',0,0,'C');
$this->Cell(10,5,'Tipo:',0,0,'C');
$this->Cell(30,5,$tipo,1,0,'C');
$this->Cell(6,5,'',0,0,'C');
$this->Cell(12,5,'fecha:',0,0,'C');
$this->Cell(25,5,$fecha,1,0,'C');
$this->Cell(7,5,'',0,0,'C');
$this->Cell(7,5,'No:',0,0,'C');
$this->Cell(10,5,$id,1,0,'C');
$this->Ln(8);
//Encabezado de la tabla
$this->SetFont('Arial','',10);
$this->SetFillColor(200,220,255);
$this->Cell(15,5,'ITEM',1,0,'C','T');
$this->Cell(60,5,'DESCRIPCION',1,0,'C','T');
$this->Cell(20,5,'UNIDAD',1,0,'C','T');
$this->Cell(15,5,'CANT.',1,0,'C','T');
$this->Cell(27,5,'ESTADO',1,0,'C','T');
$this->Cell(53,5,'OBSERVACIONES',1,0,'C','T');
//celdas de la tabla
$this->Ln();
$this->SetFont('Arial','',10);
$this->SetFillColor(200,220,255);
$this->Cell(15,5,'',1,0,'C');
$this->Cell(60,5,'',1,0,'C');
$this->Cell(20,5,'',1,0,'C');
$this->Cell(15,5,'',1,0,'C');
$this->Cell(27,5,'',1,0,'C');
$this->Cell(53,5,'',1,0,'C');
}
//Pie de página
function Footer()
{
//Posición
$this->SetY(-27);
//Fuente
$this->SetFont('Arial','',10);
//Número de página
$this->Cell(95,9,'ENTREGO',1,0,'C');
$this->Cell(95,9,'RECIBIO',1,0,'C');
$this->Ln();
$this->Cell(20,5,'NOMBRE',1,0,'C');
$this->Cell(75,5,'',1,0,'C');
$this->Cell(20,5,'NOMBRE',1,0,'C');
$this->Cell(75,5,'',1,0,'C');
$this->Ln();
$this->Cell(20,5,'CARGO',1,0,'C');
$this->Cell(75,5,'',1,0,'C');
$this->Cell(20,5,'CARGO',1,0,'C');
$this->Cell(75,5,'',1,0,'C');
$this->Ln();
$this->Cell(20,5,'FIRMA',1,0,'C');
$this->Cell(75,5,'',1,0,'C');
$this->Cell(20,5,'FIRMA',1,0,'C');
$this->Cell(75,5,'',1,0,'C');
}
}
//Impresion 
$pdf=new PDF();
$pdf->SetY(65);
$pdf->Output();
?>
Gracias.
  #2 (permalink)  
Antiguo 26/03/2014, 09:05
 
Fecha de Ingreso: junio-2011
Ubicación: Barcelona
Mensajes: 212
Antigüedad: 12 años, 10 meses
Puntos: 17
Respuesta: variables fpdf en php y mysql

Si los datos los sacas de una base de datos donde tienes tienes el bucle para recorrer esos datos en //celdas de la tabla?

Un saludo.
__________________
Twitter: @ed33x
  #3 (permalink)  
Antiguo 26/03/2014, 09:46
Avatar de letingel  
Fecha de Ingreso: noviembre-2013
Ubicación: neiva
Mensajes: 41
Antigüedad: 10 años, 5 meses
Puntos: 0
Respuesta: variables fpdf en php y mysql

Buenas un poco tarde pero ya tengo la solución
solo metí la consultas dentro de una sola función y el bucle que la repite ya esta, funciona a la perfección
aquí el link:

http://www.ctrlobra.letingel.com/usu....php?id_item=3

aquí el codigo

Código PHP:
Ver original
  1. <?php
  2. include('../../conexion.php');
  3. include('fpdf/fpdf.php');
  4. header("Content-Type: text/html; charset=iso-8859-1 ");
  5. class PDF extends FPDF
  6. {
  7. function Header()
  8. {
  9. //Variables para consulta
  10. $id_salidas = $_GET['id_item'];
  11. //Consulta sql encabezado
  12. $query1 = mysql_query("SELECT * FROM salida_ingreso WHERE id_salida_ingreso = '$id_salidas'");
  13. $encabezado = mysql_fetch_array($query1, $conexion);
  14. //Variables para encabezado
  15.     $destino = $encabezado['destino'];
  16.     $tipo = $encabezado['tipo_solicitud'];
  17.     $fecha = $encabezado['fecha2'];
  18.     $id = $encabezado['id_salida_ingreso'];
  19. //Logo
  20. $this->Image("images/logo.jpg",12,11,35,19,"JPG");
  21. //Arial bold 15
  22. $this->SetFont('Arial','',12);
  23. //Encabezado
  24. $this->Cell(40,20,'',1,0,'r');
  25. $this->Cell(88,10,'Sistema Integrado de Gestion',1,0,'C');
  26. $this->Cell(30,5,'Vigencia',1,0,'C');
  27. $this->Cell(33,5,'Marzo 26 de 2014',1,0,'C');
  28. $this->Ln(5);
  29. $this->Cell(128);
  30. $this->Cell(30,5,'Pagina',1,0,'C');
  31. $this->Cell(32,5,'1 de 1',1,0,'C');
  32. $this->Ln(5);
  33. $this->Cell(40);
  34. $this->Cell(88,10,'Salida e ingreso de almacen',1,0,'C');
  35. $this->Cell(30,5,'Codigo',1,0,'C');
  36. $this->Cell(32,5,'GANA-RE-002',1,0,'C');
  37. $this->Ln(5);
  38. $this->Cell(128);
  39. $this->Cell(30,5,'Version',1,0,'C');
  40. $this->Cell(32,5,'001',1,0,'C');
  41. //Contenido del formulario
  42. $this->Ln(8);
  43. $this->SetFont('Arial','',12);
  44. $this->SetFillColor(200,220,255);
  45. $this->Cell(25,5,'Uso/destino:',0,0,'C');
  46. $this->Cell(50,5,$destino,1,0,'C');
  47. $this->Cell(8,5,'',0,0,'C');
  48. $this->Cell(10,5,'Tipo:',0,0,'C');
  49. $this->Cell(30,5,$tipo,1,0,'C');
  50. $this->Cell(6,5,'',0,0,'C');
  51. $this->Cell(12,5,'fecha:',0,0,'C');
  52. $this->Cell(25,5,$fecha,1,0,'C');
  53. $this->Cell(7,5,'',0,0,'C');
  54. $this->Cell(7,5,'No:',0,0,'C');
  55. $this->Cell(10,5,$id,1,0,'C');
  56. $this->Ln(8);
  57. //Encabezado de la tabla
  58. $this->SetFont('Arial','',10);
  59. $this->SetFillColor(200,220,255);
  60. $this->Cell(15,5,'ITEM',1,0,'C','T');
  61. $this->Cell(68,5,'DESCRIPCION',1,0,'C','T');
  62. $this->Cell(12,5,'CANT.',1,0,'C','T');
  63. $this->Cell(15,5,'UNID.',1,0,'C','T');
  64. $this->Cell(27,5,'ESTADO',1,0,'C','T');
  65. $this->Cell(53,5,'OBSERVACIONES',1,0,'C','T');
  66. //ciclo de repeticion celdas
  67. //Consulta para cuerpo tabla
  68. $sql = "SELECT * FROM items_2 WHERE id_acta = '$id'";
  69. $cuerpo = mysql_query($sql);
  70. while ($row = mysql_fetch_row($cuerpo)){
  71. //celdas de la tabla
  72. $this->Ln();
  73. $this->SetFont('Arial','',10);
  74. $this->SetFillColor(200,220,255);
  75. $this->Cell(15,5,$row[0],1,0,'C');
  76. $this->Cell(68,5,$row[2],1,0,'C');
  77. $this->Cell(12,5,$row[3],1,0,'C');
  78. $this->Cell(15,5,$row[4],1,0,'C');
  79. $this->Cell(27,5,$row[5],1,0,'C');
  80. $this->Cell(53,5,$row[6],1,0,'C');
  81. }
  82. }
  83. function Footer()
  84. {
  85. //Variables para consulta
  86. $id_salidas = $_GET['id_item'];
  87. //Consulta sql pie de pagina
  88. $query1 = mysql_query("SELECT * FROM salida_ingreso WHERE id_salida_ingreso = '$id_salidas'");
  89. $encabezado = mysql_fetch_array($query1, $conexion);
  90. //Variables para pie de pagina
  91.     $entrega = $encabezado['entrega'];
  92.     $recibe = $encabezado['recibe'];
  93. //Posición
  94. $this->SetY(-27);
  95. //Fuente
  96. $this->SetFont('Arial','',10);
  97. //Número de página
  98. $this->Cell(95,9,'ENTREGO',1,0,'C');
  99. $this->Cell(95,9,'RECIBIO',1,0,'C');
  100. $this->Ln();
  101. $this->Cell(20,5,'NOMBRE',1,0,'C');
  102. $this->SetFont('Arial','',12);
  103. $this->Cell(75,5,$entrega,1,0,'C');
  104. $this->Cell(20,5,'NOMBRE',1,0,'C');
  105. $this->SetFont('Arial','',12);
  106. $this->Cell(75,5,$recibe,1,0,'C');
  107. $this->SetFont('Arial','',10);
  108. $this->Ln();
  109. $this->Cell(20,5,'CARGO',1,0,'C');
  110. $this->Cell(75,5,'',1,0,'C');
  111. $this->Cell(20,5,'CARGO',1,0,'C');
  112. $this->Cell(75,5,'',1,0,'C');
  113. $this->Ln();
  114. $this->Cell(20,5,'FIRMA',1,0,'C');
  115. $this->Cell(75,5,'',1,0,'C');
  116. $this->Cell(20,5,'FIRMA',1,0,'C');
  117. $this->Cell(75,5,'',1,0,'C');
  118. }
  119. }
  120. //Impresion
  121. $pdf=new PDF();
  122. $pdf->Output();
  123. ?>

Gracias de todas formas

Etiquetas: fecha, formulario, html, mysql, select, sql, tabla, usuarios, variable, variables
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 13:31.