david thompson Posted September 5, 2010 Report Posted September 5, 2010 Hello, I have this and for some reason the flag and text doesnt line up? any ideas? my code is... <table width="700px" border="0" cellspacing="0" cellpadding="1"> <?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>'; ?> regards Quote
Administrators simpilot Posted September 5, 2010 Administrators Report Posted September 5, 2010 There are a few things going on there. It looks like you are decaring a table twice at the start, and also the header row has no <tr></tr> tags. I did it a little differently and posted it below. You will have to fit it into a div on your template or determine the width in the table declaration. As far as things not staying on the same row, when you limit the width of a cell, like is done in the code you posted, the browser will break up the data to fit into the cell. It will do the same thing if the table is restricted to a certain width. <?php echo '<table cellspacing="1" cellpadding="1" border="1">'; echo '<tr>'; echo '<th align="left">Country Location</th>'; echo '<th align="center">Pilots</th>'; echo '</tr>'; $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>'; ?> Quote
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.