in2tech Posted March 11, 2018 Report Share Posted March 11, 2018 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! Quote Link to comment Share on other sites More sharing options...
web541 Posted March 11, 2018 Report Share Posted March 11, 2018 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> Quote Link to comment Share on other sites More sharing options...
in2tech Posted March 12, 2018 Author Report Share Posted March 12, 2018 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.