Ver Mensaje Individual
  #4 (permalink)  
Antiguo 05/07/2010, 06:09
johhan16
 
Fecha de Ingreso: junio-2010
Ubicación: Venezuela, Zulia
Mensajes: 686
Antigüedad: 13 años, 10 meses
Puntos: 55
Respuesta: Quien me explica como funciona FPDF con PHP

estoy probando este codigo

Código PHP:
<?php
//SHOW A DATABASE ON A PDF FILE
//CREATED BY: Carlos Vasquez S.
//E-MAIL: [email protected]
//CVS TECNOLOGIA E INNOVACION
//SANTIAGO, CHILE

require('fpdf/fpdf.php');

//Connect to your database
include("cone.php");

//Select the Products you want to show in your PDF file
$result=mysql_query("select * from docente",$link);
$number_of_products mysql_numrows($result);

//Initialize the 3 columns and the total
$cod_doc1 "";
$cedula1 "";
$nombre1 "";

//For each row, add the field to the corresponding column
while($row mysql_fetch_array($result))
{
    
$codigo $row["cod_doc"];
    
$cedula $row["cedula"];
    
$nombre substr($row["nombre"],0,20);

    
$cod_doc1 $cod_doc1.$codigo."\n";
    
$cedula1 $cedula1.$cedula."\n";
    
$nombre1 $nombre1.$nombre."\n";

}
mysql_close();


//Create a new PDF file
$pdf=new FPDF();
$pdf->AddPage();

//Fields Name position
$Y_Fields_Name_position 20;
//Table position, under Fields Name
$Y_Table_Position 26;

//First create each Field Name
//Gray color filling each Field Name box
$pdf->SetFillColor(232,232,232);
//Bold Font for Field Name
$pdf->SetFont('Arial','B',12);
$pdf->SetY($Y_Fields_Name_position);
$pdf->SetX(45);
$pdf->Cell(20,6,'cod_doc',1,0,'L',1);
$pdf->SetX(65);
$pdf->Cell(100,6,'cedula',1,0,'L',1);
$pdf->SetX(135);
$pdf->Cell(30,6,'nombre',1,0,'R',1);
$pdf->Ln();

//Now show the 3 columns
$pdf->SetFont('Arial','',12);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(45);
$pdf->MultiCell(20,6,$cod_doc1,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(65);
$pdf->MultiCell(100,6,$cedula1,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(135);
$pdf->MultiCell(30,6,$nombre1,1,'R');


//Create lines (boxes) for each ROW (Product)
//If you don't use the following code, you don't create the lines separating each row
$i 0;
$pdf->SetY($Y_Table_Position);
while (
$i $number_of_products)
{
    
$pdf->SetX(45);
    
$pdf->MultiCell(120,6,'',1);
    
$i $i +1;
}

$pdf->Output();
?>

y me da el siguiente error
FPDF error: Some data has already been output, can't send PDF file

entonces quite la linea
Código PHP:
include("cone.php"); 
y funciono, por supuesto sin hacer la consulta