I wrote a PHP code to get top list player from a WordPress quiz plugin. My problem is that I want to get an array that contains all the users and echo
it. I don't know how to do it all the method I do gives me an error.
Here my latest code these one produces me only one results
<?php
global $wpdb;
$sql = "SELECT * FROM wp_wp_pro_quiz_toplist order by points DESC";
$result = $wpdb->get_results($sql) or die(mysql_error());
foreach( $result as $results ) {
$name = array();
$points = array();
$name = $results->name;
$points= $results->points;
}
?>
Here is an example of the echo
data:
<div class='col-md-2 col-md-offset-5 topplayers text-center item '>
<ul list-unstyled list-inline>
<li>
<div class='players'>
<img src='<?php echo esc_url(get_template_directory_uri()); ?>/img/logo2.png' alt='cgce-revision'>
</div>
<p class='played'>
player : <?php echo $name; ?>
</p>
<p>
scored : <?php echo $points; ?>
</p>
</li>
</div>