Jump to content

Only Top Ten Domiciles


in2tech

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!

Link to comment
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>

 

Link to comment
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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...