Moderators mark1million Posted May 6, 2010 Moderators Report Share Posted May 6, 2010 Nabeel, i have a pilots list currently displayed in the va stats, listed i have all the countries displaying the flag and location in a table (for anyone else this is the code)Page in action <?php echo '<td align="center" 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>'; ?> Now my question is how can i split this display in to four columns as the one long list looks a bit odd, hope you know what i mean Thanks Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted May 6, 2010 Administrators Report Share Posted May 6, 2010 Not sure if this is what you are thinking but give it a try... <?php $country_info = DB::get_results('SELECT COUNT(pilotid) as total, location FROM '.TABLE_PREFIX.'pilots GROUP BY LOCATION'); $country_count = DB::get_row('SELECT COUNT(DISTINCT location) AS tot FROM '.TABLE_PREFIX.'pilots'); $column = '0'; if($country_count->tot >= 2) { $column = '1'; } if($column == '1') { echo '<table cellspacing="1" cellpadding="1" border="1">'; echo '<tr><th width="150px"><div align="left">Country Location</div></th>'; echo '<th width="100px"><div align="center">Pilots</div></th>'; echo '<th width="150px"><div align="left">Country Location</div></th>'; echo '<th width="100px"><div align="center">Pilots</div></th></tr>'; foreach($country_info as $country) { if ($column % 2) { 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>'; if (!$column % 2) { echo '</tr>'; } $column++; } if (!$column % 2) { echo '<td>Â </td><td>Â </td></tr>'; } echo '</table>'; } else { 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>'; 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>'; } ?> Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted May 6, 2010 Author Moderators Report Share Posted May 6, 2010 Thank you Dave, thats just what im after. Top man, to the rescue again Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted May 6, 2010 Administrators Report Share Posted May 6, 2010 Cool, moving to Code Snippets 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.