gpt4 book ai didi

php - 为什么我只得到 1 行 ans?

转载 作者:行者123 更新时间:2023-11-29 11:29:19 24 4
gpt4 key购买 nike

while($row = mysql_fetch_array($result))
{
if (isset($row["name"]) && ($row["name"] != "")){
$contentStr = $row["名称"];
}
休息;
}
mysql_close($con);

这可行,但不是我想要的方式。我想展示我得到的所有数据。示例中现在数据库中有 4 个数据,并使用\n 作为下一行来显示另一个数据。格式怎么写?

最佳答案

首先,删除中断。它没有任何作用。

现在,我相信您想要做的是将所有 row["name"] 值获取到一个字符串中,即 $contentStr,以换行符分隔。

如果是这种情况,请使用以下内容:

$contentStr .= $row["name"] . "\n"

此外,请确保在循环之前创建一个空的 $contentStr。

关于php - 为什么我只得到 1 行 ans?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37678125/

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