// now we run the query again to get the total rows...// the query is identical except we count the rows instead$sql_ary['SELECT'] = 'COUNT(u.user_id) as total_users';$sql = $db->sql_build_query('SELECT', $sql_ary);$result = $db->sql_query($sql);

// get the total users, this is a single row, single field.$total_users = $db->sql_fetchfield('total_users');// free the result$db->sql_freeresult($result);