mysql_num_rows总是返回1

时间:2014-04-29 15:11:36

标签: php

似乎num_rows变量为1,无论是什么...... 我是否正确使用此功能?

 //get the oldest review date still open
    $check_sql = "SELECT max(review_date) as max_date"
       . " from employee_reviews"
       . " WHERE review_status = '0' and emp_no = '" . [v_emp_no] . "'";
    // run query against database   
    $oldest_review_open = mysql_query("$check_sql"); 
    // retrieve a count of the rows in the previous query
    $num_rows = mysql_num_rows($oldest_review_open); 
    echo $num_rows;
抓头......

提前致谢

1 个答案:

答案 0 :(得分:0)

您正在使用累积函数,无论计算多少行,此函数只返回一行。

您可以使用以下方法再次查看:

$check_sql = "SELECT review_date"
       . " from employee_reviews"
       . " WHERE review_status = '0' and emp_no = '" . [v_emp_no] . "'";