How to limit the output of data in the table to 10? I have a plugin for WordPress, this is a code of a certain rating:
$groups_array = array();
$sql_groups = $wpdb->get_results("SELECT * FROM $table_group");
foreach($sql_groups as $sql_groups_new)
{
$a_group_id = $sql_groups_new->id;
$a_group_name = $sql_groups_new->name;
$sql_members = $wpdb->get_results("SELECT * FROM $table_members where group_id = '$a_group_id'");
foreach($sql_members as $sql_members_new)
{
$a_member_id = $sql_members_new->user_id;
$sql_pointer = $wpdb->get_results("SELECT meta_value FROM $table_matauser where user_id = '$a_member_id' AND meta_key = '_gamipress_star_points' ");
foreach($sql_pointer as $sql_pointer_new)
{
$a_groups_points = $sql_pointer_new->meta_value;
$groups_array[$a_group_name] += $a_groups_points;
}
}
}
array_filter($groups_array);
arsort($groups_array);
$icount_rank = 0;
?>
<table>
<tr>
<th>
Rank
</th>
<th>
Group
</th>
<th>
Points
</th>
</tr>
<?php
foreach($groups_array as $groups_array_title => $groups_array_points)
{
$icount_rank++;
echo '<tr>';
echo '<td>';
echo $icount_rank;
echo '</td>';
echo '<td>';
echo $groups_array_title;
echo '</td>';
echo '<td>';
echo $groups_array_points;
echo '</td>';
echo '</tr>';
}
?>
</table>
<?php
}
?>
I would not want to change something in the database, since I need to display both all the data and a limited amount, in my case 10.