gpt4 book ai didi

php pdo fetchAll

转载 作者:太空宇宙 更新时间:2023-11-03 12:15:49 25 4
gpt4 key购买 nike

我正在使用 fluentpdo - https://github.com/lichtner/fluentpdo

我正在尝试使用此代码将表中的结果循环到 html

$bxslider = $fpdo->from('bxslider')->select('box_img, box_link, box_title, box_desc');

但是我只得到 1 个结果

foreach ($bxslider as $bx) {
$BXSLIDER = "<li>";
$BXSLIDER .= "<em>";
$BXSLIDER .= "<img src='{$bx['box_img']}' alt='{$bx['box_title']}' />";
$BXSLIDER .= "<a href='{$bx['box_link']}'><i class='fa fa-link icon-hover icon-hover-1'></i></a>";
$BXSLIDER .= "<a href='{$bx['box_img']}' class='fancybox-button' title='{$bx['box_title']}' data-rel='fancybox-button'><i class='fa fa-search icon-hover icon-hover-2'></i></a>";
$BXSLIDER .= "</em>";
$BXSLIDER .= "<a class='bxslider-block' href='#'>";
$BXSLIDER .= "<strong>{$bx['box_title']}</strong>";
$BXSLIDER .= "<b>{$bx['box_desc']}</b>";
$BXSLIDER .= "</a>";
$BXSLIDER .= "</li>";
}

print $BXSLIDER;

如何显示所有结果?

问题不是来自 fluentpdo 类,因为我使用了另一个类,甚至是来自 PHP 的简单 pdo 类,我仍然有同样的问题...

提前致谢...

最佳答案

您正在用每个 foreach 循环覆盖 $BXSLIDER。你需要做这样的事情:

$BXSLIDER = "";
foreach ($bxslider as $bx) {

$BXSLIDER .= "<li>";
$BXSLIDER .= "<em>";
$BXSLIDER .= "<img src='{$bx['box_img']}' alt='{$bx['box_title']}' />";
$BXSLIDER .= "<a href='{$bx['box_link']}'><i class='fa fa-link icon-hover icon-hover-1'></i></a>";
$BXSLIDER .= "<a href='{$bx['box_img']}' class='fancybox-button' title='{$bx['box_title']}' data-rel='fancybox-button'><i class='fa fa-search icon-hover icon-hover-2'></i></a>";
$BXSLIDER .= "</em>";
$BXSLIDER .= "<a class='bxslider-block' href='#'>";
$BXSLIDER .= "<strong>{$bx['box_title']}</strong>";
$BXSLIDER .= "<b>{$bx['box_desc']}</b>";
$BXSLIDER .= "</a>";
$BXSLIDER .= "</li>";

}

print $BXSLIDER;

关于php pdo fetchAll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22281199/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com