PHP echo不会打印值

时间:2014-11-06 09:59:54

标签: php mysql

我正在尝试解决php中的问题,但我还没有找到解决方案。

这是代码:

$sql = mysql_query("SELECT pl_scored_goal, (pl_scored_goal - @min) as diff FROM hb_games");
while($row = mysql_fetch_array($sql)){
echo $row['diff'];
}

$sql查询在phpMyAdmin上正常运行,并显示结果0 -9,但上面的回显不起作用。

我也试图找出可能的错误:

print_r($sql)//result Resource id #9
var_dump($row['diff']//result NULL NULL

我不明白为什么我不能回应价值观。

2 个答案:

答案 0 :(得分:0)

只是一个猜测,尝试(pl_scored_goal - COALESCE(@min,0))为差异

答案 1 :(得分:0)

希望这会对你有所帮助,试试这个:

$sql = mysql_query("SELECT pl_scored_goal, (pl_scored_goal - @min) as diff FROM hb_games");
while($row = mysql_fetch_object($sql)){
echo"
".$row->diff; }