I am starting to use the FPDF library and I need to generate a PDF document with the records of my "winners" table. So far I was able to generate the PDF document but I could not list the records of my table, I would appreciate any help.
I know that in my query what I ask is that you return all the records, previously I did it with the fields "id" and "nombre_triun", I put it that way because I can not think of any more ideas and I was trying several ways to solve this but nothing, so I left the code as it was at the time of finishing one of the many tests carried out:
<?php
include('fpdf/fpdf.php');<br>
include('conexion-modelo.php');
class Conectar extends Conexion{
public $pdoSTMT;
public function __construct(){
Conexion::realizandoConexion();
}
public function querySQL(){
$stmt = Conexion::query("SELECT * FROM triunfadores");
return $stmt;
}
}
class PDF extends FPDF{
function header(){
$this->Cell(5,5,'id','C');
$this->Cell(5,5,'nombre_triun','C');
}
}
$obj = new Conectar();
$pdf = new PDF();
$pdf->SetFont('Arial','B',12);
$pdf->AddPage();
$datos = $obj -> querySQL();
while($row = $datos->fetchAll(PDO::FETCH_ASSOC)){
echo $row["id"];
}
$pdf->Output();
?>