How to show 1-5 of X Total Results

it’s been a long time, I had exact the same task and here is the solution

$from = ($query->query_vars['posts_per_page'] * $paged) - ($query->query_vars['posts_per_page'] - 1);
if(($query->query_vars['posts_per_page'] * $paged) <= ($query->found_posts)){
  $to = ($query->query_vars['posts_per_page'] * $paged);
}else{
  $to = $query->found_posts;
}
if($from == $to){
  $from_to = $from;
}else{
  $from_to = $from.' - '.$to;
}

It’s not the perfect code, but it works in most of situation.
Have a nice day!)

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)