如何使用php和sql在fpdf中使用foreach循环显示多条记录

9nvpjoqh  于 2023-01-19  发布在  PHP
关注(0)|答案(1)|浏览(113)

我正在使用fpdf,它使用foreach循环显示多个记录,但是它说“连接忙碌处理另一个命令的结果”。

$id = $_GET['id'];
$stmts = $database->prepare("SELECT * FROM inv_dealerscardsuppliers WHERE id = :id");
$stmts->bindParam(':id',$id);
$stmts->execute();
$resultsuppliers = $stmts->fetch(PDO::FETCH_ASSOC);

foreach ($resultsuppliers as $rowsuppliers) {
            $pdf->cell(w:'47.5', h:'6', txt:$rowsuppliers['major'], border:'1', ln:'0',align:'L');      
            $pdf->cell(w:'47.5', h:'6', txt:$rowsuppliers['brand'], border:'1', ln:'0', align:'L');
            $pdf->cell(w:'47.5', h:'6', txt:$rowsuppliers['terms'], border:'1', ln:'0',align:'L');
            $pdf->cell(w:'47.5', h:'6', txt:$rowsuppliers['credit'], border:'1', ln:'0',align:'L');
        }
w8rqjzmb

w8rqjzmb1#

$id = $_GET['id'];
$stmts = $database->prepare("SELECT * FROM inv_dealerscardsuppliers WHERE id = :id");
$stmts->bindParam(':id',$id);
$stmts->execute();
$resultsuppliers = $stmts->fetchAll(PDO::FETCH_ASSOC);

foreach ($resultsuppliers as $rowsuppliers) {
            $pdf->cell(w:'47.5', h:'6', txt:$rowsuppliers['major'], border:'1', ln:'0',align:'L');      
            $pdf->cell(w:'47.5', h:'6', txt:$rowsuppliers['brand'], border:'1', ln:'0', align:'L');
            $pdf->cell(w:'47.5', h:'6', txt:$rowsuppliers['terms'], border:'1', ln:'0',align:'L');
            $pdf->cell(w:'47.5', h:'6', txt:$rowsuppliers['credit'], border:'1', ln:'0',align:'L');
        }

相关问题