<?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 be while ($row = mysql_fetch_array($sqls)){
这会引起问题吗
关于php - 我的 PHP MySQL while 循环不返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8109787/