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";
        }
}

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.