gpt4 book ai didi

php - 如何正确从数据库中检索

转载 作者:行者123 更新时间:2023-11-29 09:02:42 25 4
gpt4 key购买 nike

我是 PHP 新手,在提取这些数据时遇到问题。它正在根据调试器查找记录,但由于某种原因,页面变为空白。任何人都可以帮我用这个 for 循环来检索字段吗?我认为这就是问题所在。我尝试过使用和不使用 while 循环(我认为这是错误的),但没有任何结果

 echo '<table class="table_content">
<tr>
<td class="td_order" colspan="3" width="800px">
Descriptions </td>
</tr><tr>';

for($counter = 0; $row2 = mysql_fetch_row($result2); $counter++)
{

while ($row2 = mysql_fetch_assoc($result)) {
$_name = $row["_name"];
$_image = $row["_image"];
$_disc = $row["_disc"];
}
print("<td valign='top' width='230px' height='300px'>");
print("<p style='font-size:18px; color:blue; padding:0;'>$_name</p>");
print("<img class='custom' alt='' src='$_image'/>");
print("<p>$_disc</p>");
print('</td>');
}
}

echo '</tr></table> ';

我认为我的循环逻辑做错了,我尝试了几件事..但没有任何结果...我将感谢您的帮助。

PS:连接有效,查询有效。正在检索的数据是愚蠢的

_name        _image                _disc   
Benjamin images/benjamin.jpg He's a great person
Jairo images/jairo.jpg Jairo has experience as a civil engineer..

最佳答案

删除 for 和 while 循环并用 ; 进行更改

while($row = mysql_fetch_array( $result )){
$_name = $row["_name"];
$_image = $row["_image"];
$_disc = $row["_disc"];
..

关于php - 如何正确从数据库中检索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8114783/

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