Kryptix Posted December 23, 2011 Share Posted December 23, 2011 I have a <div> that's 250px wide and inside that I want to display the top forum posters like: 1. User 3,298 2. Another User 2,385 ...etc I want their post count to be centred right and I want the rest to he centred left. Is this possible to do somehow just using a <ul> <li>? If not, what's the best/sleekest way to do it using the least code as possible? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/253734-whats-the-best-way-to-display-table-data/ Share on other sites More sharing options...
Stiver112 Posted December 23, 2011 Share Posted December 23, 2011 Isnt the anwser obvious?... tables: <table></table> Or is it just me that do not understand the question? Quote Link to comment https://forums.phpfreaks.com/topic/253734-whats-the-best-way-to-display-table-data/#findComment-1300837 Share on other sites More sharing options...
scootstah Posted December 23, 2011 Share Posted December 23, 2011 Tables are meant for tabular data - there's nothing wrong with using tables in this case. In fact, trying to make faux tables with other structures is kind of silly. Quote Link to comment https://forums.phpfreaks.com/topic/253734-whats-the-best-way-to-display-table-data/#findComment-1300870 Share on other sites More sharing options...
ManiacDan Posted December 23, 2011 Share Posted December 23, 2011 The rule is to not use tables for LAYOUT. That means: don't use tables to organize your site, don't use tables to make an image float to the right of a paragraph, and don't use tables to make your header look nice. DO use tables for TABLES. The tag is not deprecated, it's just incorrectly used. Quote Link to comment https://forums.phpfreaks.com/topic/253734-whats-the-best-way-to-display-table-data/#findComment-1300876 Share on other sites More sharing options...
Kryptix Posted December 24, 2011 Author Share Posted December 24, 2011 Alright thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/253734-whats-the-best-way-to-display-table-data/#findComment-1301059 Share on other sites More sharing options...
Kryptix Posted December 24, 2011 Author Share Posted December 24, 2011 I'd like to still use <ul> so I can have a number next to each top poster, I'm not sure how I'd incorporate that into a table with 2 columns (one for their rank and name and one for their post count)? Quote Link to comment https://forums.phpfreaks.com/topic/253734-whats-the-best-way-to-display-table-data/#findComment-1301060 Share on other sites More sharing options...
scootstah Posted December 24, 2011 Share Posted December 24, 2011 Are you using PHP to loop through database results? If so then just use the loop to add numbers. $i = 1; while($row = mysql_fetch_assoc($result)) { echo '<tr> <td>' . $i . '</td> <td>' . $row['username'] . '</td> </tr>'; $i++; } Quote Link to comment https://forums.phpfreaks.com/topic/253734-whats-the-best-way-to-display-table-data/#findComment-1301063 Share on other sites More sharing options...
Kryptix Posted December 24, 2011 Author Share Posted December 24, 2011 I am, and I usually do that, but I'm trying to make the website as fast and efficiently as possible with the least amount of code, I'd much sooner use a list to auto add numbers to the list, but wasn't sure how I could incorporate that into a table. Could I not just put a <span>post count</span> inside the <li> and float it to the right or should I definitely be using a table? Quote Link to comment https://forums.phpfreaks.com/topic/253734-whats-the-best-way-to-display-table-data/#findComment-1301071 Share on other sites More sharing options...
scootstah Posted December 24, 2011 Share Posted December 24, 2011 If it's a stupidly simple list, then yes you could do that. Nothing is preventing you. But hacking other structures to replicate tables is more inefficient than incrementing a variable. Quote Link to comment https://forums.phpfreaks.com/topic/253734-whats-the-best-way-to-display-table-data/#findComment-1301085 Share on other sites More sharing options...
kevinblevins Posted January 17, 2012 Share Posted January 17, 2012 Tables are meant for tabular data - there's nothing wrong with using tables in this case. In fact, trying to make faux tables with other structures is kind of silly. Quote Link to comment https://forums.phpfreaks.com/topic/253734-whats-the-best-way-to-display-table-data/#findComment-1308467 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.