Jump to content

Ayuda FPDF-PHP-MySQL


Recommended Posts

Necesito ayuda para realizar un PDF utilizando la librería FPDF.

 

Ocupé HTMLTable de FPDF para poder cargar las tablas en el PDF, pero los datos que obtengo desde mi BD con unos select no me los imprime.

Imprime las tablas y los datos como <?php echo $i; ?> en vez de salir el valor.

 

 

$htmlTable='<?php $p=0 ?>
<TABLE>
 <TR> 
   <TD colspan="4">ORIGINAL</TD>
   <TD colspan="3">ACORDADO</TD>
 </TR>

 <TR> 
   <TD width="27%">AREA</TD>
   <TD width="7%">CORP.</TD>
   <TD width="13%">EMPRESAS</TD>
   <TD width="12%">UNE</TD>
   <TD width="8%">CORP.</TD>
   <TD width="13%">EMPRESAS</TD>
   <TD width="20%">UNE</TD>
 </TR>

 <TR>
   <TD>Instalaciones</TD>
   <TD><?php echo odbc_result($query,"ing");?></TD>
   <TD><?php echo odbc_result($emp,"ing");?></TD>
   <TD><?php echo $num;?></TD>
   <TD><?php echo odbc_result($query,"ing");?></TD>
   <TD><?php echo odbc_result($emp,"ing");?></TD>
   <TD><?php echo $num;?></TD>
 </TR>

  <TR> 
   <TD>Planta Externa</strong></div></TD>
   <TD><?php echo odbc_result($query2,"ing");?></TD>
   <TD><?php echo odbc_result($emp2,"ing");?></TD>
   <TD><?php echo $num2;?></TD>
   <TD><?php echo odbc_result($query2,"ing");?></TD>
   <TD><?php echo odbc_result($emp2,"ing");?></TD>
   <TD><?php echo $num2;?></TD>
 </TR>

  <TR>
    <TD>Comercial</TD>
    <TD><?php echo odbc_result($query3,"ing");?></TD>
    <TD><?php echo odbc_result($emp3,"ing");?></TD>
    <TD><?php echo $num3;?></TD>
    <TD><?php echo odbc_result($query3,"ing");?></TD>
    <TD><?php echo odbc_result($emp3,"ing");?></TD>
    <TD><?php echo $num3;?></TD>
  </TR>

 <TR> 
   <TD>TOTAL</TD>
   <TD><?php echo $tot;?></TD>
   <TD><?php echo $tot2;?></TD>
   <TD><?php echo $tot3;?></TD>
   <TD><?php echo $tot;?></TD>
   <TD><?php echo $tot2;?></TD>
   <TD><?php echo $tot3;?></TD>
 </TR>
</TABLE>';
$pdf=new PDF_HTML_Table();
$pdf->AddPage();
$pdf->SetFont('Arial','',10);
$pdf->WriteHTML("Tabla 1<BR>$htmlTable");
$pdf->Output();

Link to comment
Share on other sites

Todos los datos te los imprime asi?? por ej: en alguna columna se escribe esto: <?php echo odbc_result($query2,"ing");?>

 

en vez del contenido de la variable?

 

 

Si te fijas en esta linea $pdf->WriteHTML("Tabla 1<BR>$htmlTable");

 

 

a la función WriteHtml le estás enviando en contenido de la varible $htmlTable ...tal vez la función tenga alguna forma de impedir la inmersión de código php.

 

Yo personalmente he trabajado con fpdf, pero las varibles las colocaba de esta forma:

$pdf->Text(60,280,'con un contrato de tipo " '.$contrato.' " desde el '.$fechin.' ',justification);

 

Saludos :krider:

Link to comment
Share on other sites

No me entendiste...te digo que yo he trabajado con fpdf y he creado documentos de esa forma.....tal vez si hicieras algo como esto, parecido a lo que yo hice, te funcione:

 

$inge=odbc_result($query,"ing");
$empleados=odbc_result($emp,"ing");
$htmlTable='<?php $p=0 ?>
<TABLE>
 <TR>
<TD colspan="4">ORIGINAL</TD>
<TD colspan="3">ACORDADO</TD>
 </TR>

 <TR>
<TD width="27%">AREA</TD>
<TD width="7%">CORP.</TD>
<TD width="13%">EMPRESAS</TD>
<TD width="12%">UNE</TD>
<TD width="8%">CORP.</TD>
<TD width="13%">EMPRESAS</TD>
<TD width="20%">UNE</TD>
 </TR>

 <TR>
<TD>Instalaciones</TD>
<TD>'.$inge.'</TD>
<TD>'.$empleados.'</TD>
<TD>'.$num.'</TD>
 </TR>


</TABLE>';
$pdf=new PDF_HTML_Table();
$pdf->AddPage();
$pdf->SetFont('Arial','',10);
$pdf->WriteHTML("Tabla 1<BR>$htmlTable");
$pdf->Output();

 

Es solo de prueba, por eso lo acorte para ver si te muestra el contenido de las variables en el pdf.

 

Saludos :krider:

Edited by AshWilliams
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...