Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/12/2008, 13:00
mariosequeda
 
Fecha de Ingreso: noviembre-2008
Ubicación: En algún lugar del disco duro.
Mensajes: 95
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: ayuda con while creando PDF mediante php

a ver si con esto te despejo un poco tu duda amigo

Código PHP:
require('../fpdf.php');

//Connect to your database
include("../conectar.php");//require ('../conectar.php');

//Create new pdf file
$pdf=new FPDF();

//Disable automatic page break
$pdf->SetAutoPageBreak(false);

//Add first page
$pdf->AddPage();

//set initial y axis position per page
$y_axis_initial 20;
$y_axis 25;

//print column titles for the actual page
$pdf->SetFillColor(220,220,220);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->SetY($y_axis_initial);
$pdf->SetX(7);
$pdf->Cell(40,6,'Cliente',1,0,'L',1);
$pdf->Cell(40,6,'Detalle',1,0,'L',1);
$pdf->Cell(30,6,'Banco',1,0,'L',1);
$pdf->Cell(20,6,'Abono',1,0,'L',1);
$pdf->Cell(15,6,'Factura',1,0,'L',1);
$pdf->Cell(30,6,'Factura Vence',1,0,'L',1);
$pdf->Cell(20,6,'Deuda',1,0,'L',1);

$y_axis $y_axis $row_height;

//Select the Products you want to show in your PDF file
$result=mysql_query('SELECT * FROM movimientos_cliente, clientes WHERE cli_nom = cli_nombre ORDER BY mov_id ASC')or die ( "Error en query: $sql, el error  es: " mysql_error() );

//initialize counter
$i 0;

//Set maximum rows per page
$max 35;

//Set Row Height
$row_height 6;

while(
$row mysql_fetch_array($result))
{
    
//If the current row is the last one, create new page and print column title
    
if ($i == $max)
    {
        
$pdf->AddPage();

       
//set initial y axis position per page
       //$y_axis_initial = 20;
       
$y_axis2 25;

        
//print column titles for the current page
        
$pdf->SetFillColor(220,220,220);
        
$pdf->SetTextColor(0,0,0);
        
$pdf->SetDrawColor(0,0,0);
        
$pdf->SetFont('Arial','B',8);
        
$pdf->SetY($y_axis2);
        
$pdf->SetX(7);
        
$pdf->Cell(40,6,'Cliente',1,0,'L',1);
        
$pdf->Cell(40,6,'Detalle',1,0,'L',1);
        
$pdf->Cell(30,6,'Banco',1,0,'L',1);
        
$pdf->Cell(20,6,'Abono',1,0,'L',1);
        
$pdf->Cell(15,6,'Factura',1,0,'L',1);
        
$pdf->Cell(30,6,'Factura Vence',1,0,'L',1);
        
$pdf->Cell(20,6,'Deuda',1,0,'L',1);
        
        
//Go to next row
        
$y_axis2 $y_axis2 $row_height;
        
        
//Set $i variable to 0 (first row)
        
$i 0;
    }

    
$cli_nom $row['cli_nom'];
    
$mov_detalle $row['mov_detalle'];
    
$mov_banco $row['mov_banco'];
    
$mov_abono $row['mov_abono'];
    
$mov_factura $row['mov_factura'];
    
$fecha_factura $row['fecha_factura'];
    
$deuda_cliente $row['deuda_cliente'];
    
    
$pdf->SetFillColor(255);
    
$pdf->SetY($y_axis);
    
$pdf->SetX(7);
    
$pdf->Cell(40,6,$cli_nom,1,0,'L',1);
    
$pdf->Cell(40,6,$mov_detalle,1,0,'L',1);
    
$pdf->Cell(30,6,$mov_banco,1,0,'L',1);
    
$pdf->Cell(20,6,$mov_abono,1,0,'L',1);
    
$pdf->Cell(15,6,$mov_factura,1,0,'L',1);
    
$pdf->Cell(30,6,$fecha_factura,1,0,'L',1);
    
$pdf->Cell(20,6,$deuda_cliente,1,0,'L',1);
    

    
//Go to next row
    
$y_axis $y_axis $row_height;
    
$i $i 1;
}

//mysql_close($link);

//Create file
$pdf->Output(); 
como te das cuenta consulto de dos tablas entonces lo que tienes que buscar que campos se relacionan en ambas tablas