为什么mysql_num_row小于条件不起作用?

时间:2014-05-09 21:42:29

标签: php mysql

为什么我无法获得回音? echo $tot给了我3

出于某种原因,$ row变量在echo 'wrong'

时的值大于3 if($row < $b)
<?php 
    if($row < $b) {
        echo "good";
    } else { echo "wrong"; }

    $sql=mysql_query("SELECT ID FROM emp WHERE user='$login_session'"); // its currently zero
    $row=mysql_num_rows($sql);
    $b = 3;
    $tot=$b - $row;
    echo $tot; 
?>

1 个答案:

答案 0 :(得分:0)

使用此:

<?php
$sql=mysql_query("SELECT ID FROM emp WHERE user='$login_session'"); // its currently zero
$row=mysql_num_rows($sql);
$b = 3;
$tot=$b - $row;
echo "$tot"; 

if($row < $b) {
echo "good";
} else { echo "wrong"; }
?>

您一直在尝试输出未定义的变量。

你的代码是:

Ouput undefined variables
Assign something to this variables

我的代码顺序是:

Assign something to this variables
Ouput undefined variables
相关问题