D
D
Deefs2018-01-26 23:20:42
PHP
Deefs, 2018-01-26 23:20:42

In php, display a value that is not in the table?

How to display in php the value of SUM(VIEWS) the total number of views of each user
if it is summed through ssql query
Function

function get_top_users()
{

    $query = db()->query("SELECT id , SUM(views) , entity_id, username, first_name, last_name, gender, country, avatar, online_time, featured FROM feeds,users WHERE `timestamp` >= DATE_SUB( CURRENT_DATE, INTERVAL 90 DAY )AND id = entity_id GROUP BY `id` ORDER BY SUM(`views`) DESC LIMIT 30");
    return fetch_all($query);
}

Output of users *( only users themselves are displayed, and I need to display a number sum(Views)

<?php foreach(get_top_users(10) as $user):?>
                    <a data-toggle="tooltip" title="<?php echo get_user_name($user)?>" href="<?php echo profile_url(null, $user)?>" style="background-image: url(<?php echo get_avatar(200, $user)?>)"></a>
                <?php endforeach?>

Screenshot from ssql query where the total number of views is displayed
5a6b8d97d87e0394447320.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2018-01-27
@dimonchik2013

SUM(views) as sv

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question