Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

Count Number Of Rows SQL Query

//Count Number Of Rows
function countRows($sql_get_results, $column = '')
{
    if ($sql_get_results and $column) {
        $count = 0;
        foreach ($sql_get_results as $row) {
            $count += $row->$column;
        }
    } else {
        $count = count($sql_get_results);
    }
    if ($count) {
        return $count;
    } else {
        return "0";
    }
}
Source by learnsql.com #
 
PREVIOUS NEXT
Tagged: #Count #Number #Of #Rows #SQL #Query
ADD COMMENT
Topic
Name
4+8 =