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



我正在使用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');
}
$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');
}