How do I show just the top ten?
<table width="100%">
<?php
echo '<td width="250px" valign="top">';
echo '<table cellspacing="1" cellpadding="1" border="1">';
echo '<th width="150px"><div align="left">Country Location</div></th>';
echo '<th width="100px"><div align="center">Pilots</div></th>';
$country_info = DB::get_results('SELECT COUNT(pilotid) as total, location FROM '.TABLE_PREFIX.'pilots GROUP BY location');
foreach($country_info as $country)
{
echo '<tr>';
echo '<td align= "left">';
echo '<img src="'.Countries::getCountryImage($country->location).'" /> ';
echo Countries::getCountryName($country->location);
echo '</td>';
echo '<td align="center">';
echo ' ('.$country->total.')';
echo '</td>';
echo '</tr>';
}
echo '</table>';
?>
</table>
Thanks!
web541
March 11, 2018, 8:23pm
2
Try this
\<table width="100%"\> \<?php echo '\<td width="250px" valign="top"\>'; echo '\<table cellspacing="1" cellpadding="1" border="1"\>'; echo '\<th width="150px"\>\<div align="left"\>Country Location\</div\>\</th\>'; echo '\<th width="100px"\>\<div align="center"\>Pilots\</div\>\</th\>'; $country\_info = DB::get\_results('SELECT COUNT(pilotid) as total, location FROM '.TABLE\_PREFIX.'pilots GROUP BY location LIMIT 10'); foreach($country\_info as $country) { echo '\<tr\>'; echo '\<td align= "left"\>'; echo '\<img src="'.Countries::getCountryImage($country-\>location).'" /\> '; echo Countries::getCountryName($country-\>location); echo '\</td\>'; echo '\<td align="center"\>'; echo ' ('.$country-\>total.')'; echo '\</td\>'; echo '\</tr\>'; } echo '\</table\>'; ?\> \</table\>
Web541 it is showing 10 and thank you for that, but it is not showing the Top Ten by country if you know what I mean. I not only wanted 10 listed, but the Top Ten listed if there is a way to do that!
Thank you very much!
This is what I wanted to match my other top ten tables:
I want to list the Top Ten in order, which this is a bad example, except for USA, which would be listed first, etc…
So it would be USA, United Kingdom, Switzerland, etc… in order! And ONLY show the Top Ten!
Thanks again!