0

this line of query run in php get the right result which is 4 but I use it in php will only get 1..how come?

function totalrental(){

        $result = mysql_query("SELECT SUM(Rent_time) FROM product") or die (mysql_error());
        $count = mysql_num_rows($result);

        if ($count >= 1){

        echo $count;    
        }else{
            echo "0";
        }
}
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by JorgeM
0

Because the SQL statement returns one row. It is just that the one row has a value of 4. You aren't getting 4 rows back with the sum keyword.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.