php - How to render an array from mysql in fpdf
I'm trying to generate a pdf of a query using the FPDF library but I can't do it, it only prints the first name of the array and doesn't go through the others, the query selects the students of the group brought with a post whose credits are greater than 0, would you be so kind to point out my mistake, thanks
<?php
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
include("conection.php");
require('fpdf/fpdf.php');
$stmt = $con->prepare("SELECT student_qr FROM students WHERE student_group = ? AND student_credits > 0");
$stmt->bind_param("s", $_POST['seraching_group']);
$stmt->execute();
$result = $stmt->get_result();
$pdf = new FPDF('P','mm','A4');
$pdf -> AddPage();
$pdf -> SetFont('Arial', 'B', 11);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(0,134,255);
$pdf->SetXY(10, 115);
$pdf -> Cell(191.5,5,utf8_decode("Alumns"),0,1,'L',true);
while($row = $result->fetch_assoc())
{
$pdf-> Cell(110,50,$row["student_qr"], 1,1,'C', true);
$pdf->Ln();
}
$pdf -> Output();
mysqli_close($con);
header("Location:http://localhost/dinningRoom_08/reporte_prueba.php");
I want it to generate a PDF with each of the students of the selected group
Answer
Solution:
I was making the mistake of closing the pdf after the first traversal of the fix, with the help of my colleagues, the problem was solved and the code is functional after editing
Source