Only one product appears in the FPDF file as I do so that they all appear?

0

I have a sales page for a project and I have to pass the data of the cart to an invoice, I have the product and cart tables, and the id's of the products that were bought are stored in the cart.

$query = mysqli_query($con,"select * from productos where idProducto = 
'".$carrito['idProducto']."'");
$tax = 0; //total tax
$amount = 0; //total amount


while($productos = mysqli_fetch_array($query)){
$pdf->Cell(130  ,5,$productos['nombre'],1,0);
//add thousand separator using number_format function
$pdf->Cell(25   ,5,number_format($carrito['Cantidad']),1,0);
$pdf->Cell(34   ,5,number_format($productos['precio']),1,1,'R');//end of line
//accumulate tax and amount

$amount += $productos['precio'];
 }

I took this out of a tutorial but when I run it, I only see one of the products and I want all of them to come out, I really do not understand sql, help D:

    
asked by Desus Jenis 13.10.2018 в 19:19
source

1 answer

0

You need to indicate the write position Y of the current cell:

$fila = 5;
while($productos = mysqli_fetch_array($query)){
 $pdf -> SetY($fila);  
 $pdf->Cell(130  ,5,$productos['nombre'],1,0);
 //add thousand separator using number_format function
 $pdf->Cell(25   ,5,number_format($carrito['Cantidad']),1,0);
 $pdf->Cell(34   ,5,number_format($productos['precio']),1,1,'R');//end of line
 //accumulate tax and amount

 $amount += $productos['precio'];
 $fila++;
}

Greetings!

    
answered by 16.10.2018 в 06:27