Ver Mensaje Individual
  #3 (permalink)  
Antiguo 26/03/2014, 09:46
Avatar de letingel
letingel
 
Fecha de Ingreso: noviembre-2013
Ubicación: neiva
Mensajes: 41
Antigüedad: 10 años, 6 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