gpt4 book ai didi

php - 我的 PHP MySQL while 循环不返回结果

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

<?php
$sqls = mysql_query("SELECT weight FROM $usertablestats")
or die ("Query failed: " . mysql_error() . " Actual query: " . $query);
$ct = mysql_query ("COUNT * '$sqls'");

if ($ct > 0) {
while ($row = mysql_fetch_array($sqls));{
$weight = $row["weight"];
echo "C" . $weight;
}}
else {
echo "No stats found";
}
?>

即使表中有数据,也会输出“未找到统计信息”。

<?php
$sqls = mysql_query("SELECT weight FROM $usertablestats")
or die ("Query failed: " . mysql_error() . " Actual query: " . $query);
$ct = mysql_num_rows($sqls);

if ($ct > 0) {
while ($row = mysql_fetch_array($sqls));{
$weight = $row["weight"];
echo "C" . $weight;
}}
else {
echo "No stats found";
}
?>

这不会返回任何内容。完全没有 echo 。

我已经检查过它是否可以通过使用来访问:

<?php
$sqls = mysql_query("SELECT weight FROM $usertablestats")
or die ("Query failed: " . mysql_error() . " Actual query: " . $query);

$row = mysql_fetch_array($sqls);

echo $row;
?>

它确实返回第一个条目。

最佳答案

while 中有分号:

while ($row = mysql_fetch_array($sqls));{//should bewhile ($row = mysql_fetch_array($sqls)){

这会引起问题吗

关于php - 我的 PHP MySQL while 循环不返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8109787/

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