Answer the question
In order to leave comments, you need to log in
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);
}
<?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?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question