Jump to content
Sign in to follow this  
in2tech

Only Top Ten Domiciles

Recommended Posts

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!

Share this post


Link to post
Share on other sites

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>

 

Share this post


Link to post
Share on other sites

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:

2018-03-12_1417

I want to list the Top Ten in order, which this is a bad example, except for USA, which would be listed first, etc....

 

2018-03-12_1418

So it would be USA, United Kingdom, Switzerland, etc.... in order! And ONLY show the Top Ten!

Thanks again!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×