MySQL查询PHP和PDF仅显示第一个字符

时间:2012-02-24 14:05:34

标签: php mysql arrays foreach

我正在运行以下查询:

$sql_1 = "SELECT `mb_transactions`.`TransactionID` AS `TXID` FROM `mb_transactions`";
$data_1 = $db->query($sql_1);
$count = count($data_1, COUNT_RECURSIVE);
if ($count > 1){
        foreach ($data_1 as $transaction_1) {
        $pdf->Cell($colWidths4[0], $pdf->fontHeight($fontSize), $transaction_1['TXID'], $border, 0, 'L');
        $pdf->Cell($colWidths4[1], $pdf->fontHeight($fontSize), '', $border, 0, 'L');
        $pdf->Cell($colWidths4[2], $pdf->fontHeight($fontSize), '', $border, 0, 'L');
        $pdf->Cell($colWidths4[3], $pdf->fontHeight($fontSize), '', $border, 0, 'L');
        $pdf->Ln();
        }
}

但是我只从显示的结果中获得第一个字符。当我做var_dump($ transaction_1)时,我看到字符串(2)“11”......等等 欣赏任何人关心分享的见解

1 个答案:

答案 0 :(得分:3)

为每个

尝试此操作
while ($data = $data_1->fetchRow(DB_FETCHMODE_ASSOC)) {

}