2 issues on scroll bar in table - php

Got 2 questions regarding a table which output is below:
Question 1:
The table height is 500px, yet what I don't understand is that it looks like the content underneath which doesn't belong to the table is displayed within the table because of the scroll bar that goes so that down that it looks like the content underneath the table rows are in the table. So my question is how can I get the scroll bar to appear only if the 500px is met, rather than showing it straight away as it is doing now? How do I get the content (select box, heading, etc) be displayed underneath the table rather than in the table as it is doing in the screenshot
Question 2:
How can I get the scroll bar to be clipped on the side of the table? At the moment it is clipped just underneath the last column meaning it is taking up some of the last column's space and hence why table columns are not matching.
Below is html code of table:
<table id="tableqanda" align="center" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th width="30%" class="question">Question</th>
<th width="8%" class="option">Option Type</th>
<th width="6%" class="noofanswers">Number of Answers</th>
<th width="8%" class="answer">Answer</th>
<th width="6%" class="noofreplies">Number of Replies</th>
<th width="6%" class="noofmarks">Number of Marks</th>
<th width="12%" class="images">Images</th>
</tr>
</thead>
</table>
<div id="tableqanda_onthefly_container">
<table id="tableqanda_onthefly" align="center" cellpadding="0" cellspacing="0">
<tbody>
<?php
foreach ($arrQuestionContent as $key=>$question) {
echo '<tr class="tableqandarow">'.PHP_EOL;
echo '<td width="30%" class="question">'.htmlspecialchars($question).'</td>' . PHP_EOL;
echo '<td width="8%" class="option">'.htmlspecialchars($arrOptionType[$key]).'</td>' . PHP_EOL;
echo '<td width="6%" class="noofanswers">'.htmlspecialchars($arrNoofAnswers[$key]).'</td>' . PHP_EOL;
echo '<td width="8%" class="answers">'.htmlspecialchars($arrAnswer[$key]).'</td>' . PHP_EOL;
echo '<td width="6%" class="noofreplies">'.htmlspecialchars($arrReplyType[$key]).'</td>' . PHP_EOL;
echo '<td width="6%" class="noofmarks">'.htmlspecialchars($arrQuestionMarks[$key]).'</td>' . PHP_EOL;
echo '<td width="12%" class="images">'.htmlspecialchars($arrImageFile[$key]).'</td>' . PHP_EOL;
echo '</tr>'.PHP_EOL;
}
?>
</tbody>
</table>
<h4>PARTICIPATING STUDENTS</h4>
<p>
<strong>Number of Participating Students:</strong> <?php echo $studentnum; ?>
</p>
<p>
<strong>Current Participating Students:</strong>
<br/>
<tr>
<td>
<select name="students" id="studentslist" size="10">
<?php
if($studentnum == 0){
echo "<option disabled='disabled' class='red' value=''>No Students currently in this Assessment</option>";
}else{
while ( $currentstudentstmt->fetch() ) {
echo "<option disabled='disabled' value='$dbStudentId'>" . $dbStudentAlias . " - " . $dbStudentForename . " " . $dbStudentSurname . "</option>" . PHP_EOL;
}
}
?>
</select>
</p>
Below is CSS:
#tableqanda_onthefly_container
{
width:100%;
overflow-y: scroll;
overflow-x: hidden;
max-height:500px;
}
#tableqanda_onthefly
{
width:100%;
overflow:auto;
clear:both;
}
#tableqanda, #tableqanda_onthefly{
border:1px black solid;
border-collapse:collapse;
table-layout:fixed;
}
#tableqanda{
width:100%;
margin-left:0;
float:left;
}
#tableqanda td {
vertical-align: middle;
border:1px black solid;
border-collapse:collapse;
}
#tableqanda th{
border:1px black solid;
border-collapse:collapse;
text-align:center;
}
I want my table to remain as a scrolling table with fixed headers

UPDATE
For question 1, try setting the overflow-y property to auto. This way the scrollbar will only be displayed once the table exceeds 500px in height.
So something like:
overflow-y:auto;
instead of
overflow-y:scroll;
ORIGINAL POST:
To answer your second question, you can just add the heads of the table as another row:
<div id="tableqanda_onthefly_container">
<table id="tableqanda_onthefly" align="center" cellpadding="0" cellspacing="0">
<tr>
<th width="30%" class="question">Question</th>
<th width="8%" class="option">Option Type</th>
<th width="6%" class="noofanswers">Number of Answers</th>
<th width="8%" class="answer">Answer</th>
<th width="6%" class="noofreplies">Number of Replies</th>
<th width="6%" class="noofmarks">Number of Marks</th>
<th width="12%" class="images">Images</th>
</tr>
<?php
foreach ($arrQuestionContent as $key=>$question) {
echo '<tr class="tableqandarow">'.PHP_EOL;
echo '<td width="30%" class="question">'.htmlspecialchars($question).'</td>' . PHP_EOL;
echo '<td width="8%" class="option">'.htmlspecialchars($arrOptionType[$key]).'</td>' . PHP_EOL;
echo '<td width="6%" class="noofanswers">'.htmlspecialchars($arrNoofAnswers[$key]).'</td>' . PHP_EOL;
echo '<td width="8%" class="answers">'.htmlspecialchars($arrAnswer[$key]).'</td>' . PHP_EOL;
echo '<td width="6%" class="noofreplies">'.htmlspecialchars($arrReplyType[$key]).'</td>' . PHP_EOL;
echo '<td width="6%" class="noofmarks">'.htmlspecialchars($arrQuestionMarks[$key]).'</td>' . PHP_EOL;
echo '<td width="12%" class="images">'.htmlspecialchars($arrImageFile[$key]).'</td>' . PHP_EOL;
echo '</tr>'.PHP_EOL;
}
?>
</table>
</div>
This way the scroll bar should be put at the very right, not underneath anything. The reason it wasn't before was because you had two different tables with independent widths.

Related

TCPDF table header automatically move to the right

I have created a table with TCPDF. The header, which has a black background, has been positioned slightly to the right as though there is some padding on the left hand side. I cannot get it to line up correctly.
The code below is the HTML I have written to form the table.
$tbl ='<style>
th {background-color: black;color: white;float:left;}
.tal {text-align: left;float:left;}
</style>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<th width="60px" style="border-right: 1px solid white;"><strong>Qty</strong></th>
<th width="1px"></th>
<th class="tal" width="388px" style="padding:10px 0; border-right: 1px solid white;"> <strong>Product or Service</strong></th>
<th width="1px"></th>
<th width="84px" style="border-right: 1px solid white;"><strong>Price Each</strong></th>
<th width="1px"></th>
<th width="84px"><strong>Total</strong></th>
</tr>
<tr>
<td height="267px">';
while($i <= $a) {
$tbl .= '<table height="267px" width="60px"><tr><td>' . $productsArray['product_quantity'][$i] . '</td></tr></table>';
$i++;
}
$tbl .= '</td><td border="1" width="0.5px" height="267px" style="background:url(images/bars-black.jpg) bottom right no-repeat"></td><td height="267px">';
while($j <= $a) {
$tbl .= '<table height="267px" width="388px"><tr><td class="tal"> ' . $productsArray['product_name'][$j] . '</td></tr></table>';
$j++;
}
$tbl .= '</td><td width="0.5px" height="267px" style="background:url(images/bars-black.jpg) bottom right no-repeat"></td><td height="267px">';
while($k <= $a) {
$tbl .= '<table height="267px" width="84px"><tr><td>' . $productsArray['product_price'][$k] . '</td></tr></table>';
$k++;
}
$tbl .= '</td><td border="1" width="0.5px" height="267px" style="background:url(images/bars-black.jpg) bottom right no-repeat"></td><td height="267px">';
while($l <= $a) {
$tbl .= '<table height="267px" width="84px"><tr><td>' . $productsArray['product_sub'][$l] . '</td></tr></table>';
$l++;
}
$tbl .= '</td>
</tr>
</table>';
}
The below code is the PHP I have used to show the table on the page.
$pdf->writeHTMLCell(175, 80, 20, 100, $tbl, 1, 1, 0, true, 'C', true);
Using tables within cells of another table is generally a really bad idea and is likely contributing to the problem you are having. Since it looks like your productsArray already has all of the data you need I would simply loop through it outputting each row as you go.
It's also worth pointing out that the empty header rows that are defined with a width of 1px conflict with your actual data rows which are defined with a width of 0.5px.
<style>
th {background-color: black;color: white;float:left;}
.tal {text-align: left;float:left;}
</style>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<th width="60px" style="border-right: 1px solid white;"><strong>Qty</strong></th>
<th width="1px"></th>
<th class="tal" width="388px" style="padding:10px 0; border-right: 1px solid white;"> <strong>Product or Service</strong></th>
<th width="1px"></th>
<th width="84px" style="border-right: 1px solid white;"><strong>Price Each</strong></th>
<th width="1px"></th>
<th width="84px"><strong>Total</strong></th>
</tr>
<?php
while($i <= $a) {
?>
<tr>
<td height="267px"><?php echo $productsArray['product_quantity'][$i]; ?></td>
<td border="1" width="0.5px" height="267px" style="background:url(images/bars-black.jpg) bottom right no-repeat"></td>
<td height="267px"><?php echo $productsArray['product_name'][$i]; ?></td>
<td width="0.5px" height="267px" style="background:url(images/bars-black.jpg) bottom right no-repeat"></td>
<td height="267px"><?php echo $productsArray['product_price'][$i]; ?></td>
<td border="1" width="0.5px" height="267px" style="background:url(images/bars-black.jpg) bottom right no-repeat"></td>
<td height="267px"><?php echo $productsArray['product_sub'][$l]; ?></td>
</tr>
<?php
$i++;
}
?>
</table>

PHP Roster only showing one player on click

I am trying to put together a guild roster for my WoW guilds website. I have the roster pulling all of the right information and listing it in a table properly. The next step is to pop up a modal and display more information when clicking on one of my guild members names in the list.
Unfortunately, when I click on anyone's name in the list it only displays information of the first person in the list. Can someone please help me understand what I am doing wrong?
So you can see what I mean, go to the following link and click on any random players name in the table. No matter who you choose, it will display information about "Alisyn":
http://www.astalder.net/roster.php
Here is part of the code:
//Guild Roster Table Headers
echo " <div width='600px' align#'center'>";
echo '
<div align="center" id="roster" class="roster" style="float: none;">
<table class="warcraft sortable" border="3" cellspacing="0" cellpadding="0" align="center">
<tr>
<th width="80px" align="center" valign="top" ><strong>Race/Class</strong></a></th>
<th width="140px" align="center" valign="top" ><strong>Name</strong></a></th>
<th width="80px" align="center" valign="top" ><strong>Level</strong></a></th>
<th width="140px" align="center" valign="top" ><strong>Rank</strong></a></th>
<!-- <th width="80px" align="center" valign="top" ><strong>Message</strong></a></th> -->
</tr>';
//Character Arrays
foreach($rows as $p) {
$mrank = $p['rank'];
$mname = $p['name'];
$mclass = $p['class'];
$mrace = $p['race'];
$mlevel = $p['level'];
$mgender = $p['gender'];
$mthumbnail = $p['thumbnail'];
echo "<div id='myModal' class='reveal-modal'>
<h1><center>Details for " . $mname . "</center></h1>
<p>Name: " . $mname . "<br />
Class: " . $mclass . "<br /></p>
<a class='close-reveal-modal'>×</a>
</div>";
//#$json = file_get_contents("http://$region.battle.net/api/wow/character/$realm/$mname?fields=items", true);
//$decode = json_decode($json, true);
//$milvl = " ". $decode['items']['averageItemLevel'] . "";
//Table of Guild Members
echo "
<tr>
<td align='center'><strong><img style=\"padding-left: 5px;\" src=\"race/race_$mrace-$mgender.jpg\"></img><img style=\"padding-left: 5px;\" src=\"class/class_$mclass.jpg\"></img></strong></td>
<!-- <td class='class_$mclass' width=\"140px\" align=\"center\" valign=\"top\" ><div class=\"hover_img\"><strong>$mname<span><img src=\"http://us.battle.net/static-render/us/$mthumbnail\" alt=\"$mname\" height=\"100\"></span></strong></div></td> -->
<td class='class_$mclass' width=\"140px\" align=\"center\" valign=\"top\" ><div class=\"hover_img\"><strong>$mname<span><img src=\"http://us.battle.net/static-render/us/$mthumbnail\" alt=\"$mname\" height=\"100\"></span></strong></div></td>
<td width=\"80px\" align=\"center\" valign=\"top\" ><strong>$mlevel</strong></td>
<td sorttable_customkey='$mrank' width=\"140px\" align=\"center\" valign=\"top\" ><strong>$ranks[$mrank]</strong></td>
<!-- <td width=\"90px\" aligh=\"center\" valign=\"top\" ><div class=\"hover_img\"><img src=\"http://us.battle.net/static-render/us/$mthumbnail\"></div></td> -->
</tr>
";
}
echo " </table></div>";
Reference the rows by their unique id's. Hence when you click the name, the respective ID will be called and the player info will be displayed as per that id:
//Guild Roster Table Headers
echo " <div width='600px' align#'center'>";
echo '
<div align="center" id="roster" class="roster" style="float: none;">
<table class="warcraft sortable" border="3" cellspacing="0" cellpadding="0" align="center">
<tr>
<th width="80px" align="center" valign="top" ><strong>Race/Class</strong></a></th>
<th width="140px" align="center" valign="top" ><strong>Name</strong></a></th>
<th width="80px" align="center" valign="top" ><strong>Level</strong></a></th>
<th width="140px" align="center" valign="top" ><strong>Rank</strong></a></th>
<!-- <th width="80px" align="center" valign="top" ><strong>Message</strong></a></th> -->
</tr>';
//Character Arrays
foreach($rows as $i=>$p) {
$mrank = $p['rank'];
$mname = $p['name'];
$mclass = $p['class'];
$mrace = $p['race'];
$mlevel = $p['level'];
$mgender = $p['gender'];
$mthumbnail = $p['thumbnail'];
echo "<div id='myModal_$i' class='reveal-modal'>
<h1><center>Details for " . $mname . "</center></h1>
<p>Name: " . $mname . "<br />
Class: " . $mclass . "<br /></p>
<a class='close-reveal-modal'>×</a>
</div>";
//#$json = file_get_contents("http://$region.battle.net/api/wow/character/$realm/$mname?fields=items", true);
//$decode = json_decode($json, true);
//$milvl = " ". $decode['items']['averageItemLevel'] . "";
//Table of Guild Members
echo "
<tr>
<td align='center'><strong><img style=\"padding-left: 5px;\" src=\"race/race_$mrace-$mgender.jpg\"></img><img style=\"padding-left: 5px;\" src=\"class/class_$mclass.jpg\"></img></strong></td>
<!-- <td class='class_$mclass' width=\"140px\" align=\"center\" valign=\"top\" ><div class=\"hover_img\"><strong>$mname<span><img src=\"http://us.battle.net/static-render/us/$mthumbnail\" alt=\"$mname\" height=\"100\"></span></strong></div></td> -->
<td class='class_$mclass' width=\"140px\" align=\"center\" valign=\"top\" ><div class=\"hover_img\"><strong>$mname<span><img src=\"http://us.battle.net/static-render/us/$mthumbnail\" alt=\"$mname\" height=\"100\"></span></strong></div></td>
<td width=\"80px\" align=\"center\" valign=\"top\" ><strong>$mlevel</strong></td>
<td sorttable_customkey='$mrank' width=\"140px\" align=\"center\" valign=\"top\" ><strong>$ranks[$mrank]</strong></td>
<!-- <td width=\"90px\" aligh=\"center\" valign=\"top\" ><div class=\"hover_img\"><img src=\"http://us.battle.net/static-render/us/$mthumbnail\"></div></td> -->
</tr>
";
}
echo " </table></div>";

Show Data Horizontally in Table using PHP & MySQL

I'm trying to display data horizontally in a table by using PHP & MySQL. The code that I'm currently using is (Obviously all values will be called from MySQL but currently I have put static values):-
$query = "select * from bonusdetails where BonusType='Free Money' order by Validity ASC limit 0,3;";
$result = mysql_query($query);
echo '<table width="150" border="0" cellspacing="0" cellpadding="0" bgcolor="#941010" style="font-family:Arial, Helvetica, sans-serif; float:left; color:#ffffff;">';
while ($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td align="center" style="padding:2px 0 0 0;"><img src="abc.jpg" width="124" height="64"/></td>';
echo '</tr>';
echo '<tr>';
echo '<td align="center" style="font-size:15px; padding:8px 0 0 0;">No Deposit Bonus</td>';
echo '</tr>';
echo '<tr>';
echo '<td style="font-size:17px; padding:5px 0 0 0;" align="center" >CODE: STAR75</td>';
echo '</tr>';
echo '<tr>';
echo ' <td align="center" style="padding:8px 0 5px 0;"><a href="#"><input name="more-details" type="button" style="background:url(images/more-details.png) no-repeat; width:102px;
height:27px; text-decoration:none; border:none; cursor:pointer;" /></a></td>';
echo '</tr>';
}
echo '</table>';
I'm getting output in this format: http://www.casinobonustips.com/submitbonus/bonus.php. is there a way to display the same data horizontally?
I will highly appreciate your assistance on this.
Thanks and Regards,
Devjeet
What you have:
<table>
<tr>
<td>A1</td>
</tr>
<tr>
<td>B1</td>
</tr>
<tr>
<td>C1</td>
</tr>
<tr>
<td>A2</td>
</tr>
<tr>
<td>B2</td>
</tr>
<tr>
<td>C2</td>
</tr>
<tr>
<td>A3</td>
</tr>
<tr>
<td>B3</td>
</tr>
<tr>
<td>C3</td>
</tr>
</table>
What you should have:
<table>
<tr>
<td>
<div>A1</div>
<div>B1</div>
<div>C1</div>
</td>
<td>
<div>A2</div>
<div>B2</div>
<div>C2</div>
</td>
<td>
<div>A3</div>
<div>B3</div>
<div>C3</div>
</td>
</tr>
</table>
Example: http://jsfiddle.net/ePMmx/1/
Do your styling to suit your needs.
You need to group <td></td> in one <tr></tr> to display them "horizontally", on the other hand, you are mixing "view" stuff with processing and retrieving the data, you maybe have to read about MVC pattern for better programming

viewing database using php in different way

I am doing simple shopping site and I only know how to view the products from the database in table such as this code below.
<table width ="793" align ="center" border ="5" >
<tr bgcolor ="red">
<th width="90">product No </th>
<th>User Name </th>
<th width="184">product name</th>
<th>product price</th>
<th>Edit product</th>
<th>Delete product</th>
</tr>
<?php
mysql_connect("localhost","root","root");
mysql_select_db("db");
$query = "SELECT * FROM products";
$run = mysql_query($query);
while($row = mysql_fetch_array($run))
{
echo "<tr>";
echo '<td align="center"><font color="white"><b>' . $row['id'] . '</b></td>';
echo '<td align="center"><font color="white"><b>' . $row['product_name'] . '</b></td>';
echo '<td align="center"><font color="white"><b>' . $row['product_price'] . '</b></td>';
echo '<td align="center"><font color=" #e52d00"> <b>Edit</b></td>';
echo '<td align="center"><font color=" #e52d00"><b>Delete</b></td>';
echo "</tr>";
}
echo "</table>";
?>
</body>
</html>
and I want to know how to view data in way such as amazon or ebay. I mean inside table.
I hope you know what I mean.
Please use CSS to format the resultset..

How do I php echo this SQLDatabase data into a stylized table?

I'm trying to echo data from an SQLdatabase into a table that is somewhat decent-looking. I can already echo the data properly into 5 separate basic tables, but when I can't figure out how to style it without it completely messing up. Here is the code I already have:
// OUTPUTS RESULTS //
$resultfirst = mysql_query("SELECT * FROM Students WHERE FirstPeriod='$_POST[firstperiod]'");
$resultsecond = mysql_query("SELECT * FROM Students WHERE SecondPeriod='$_POST[secondperiod]'");
$resultthird = mysql_query("SELECT * FROM Students WHERE ThirdPeriod='$_POST[thirdperiod]'");
$resultfourth = mysql_query("SELECT * FROM Students WHERE FourthPeriod='$_POST[fourthperiod]'");
$resultfifth = mysql_query("SELECT * FROM Students WHERE FifthPeriod='$_POST[fifthperiod]'");
// 1st PERIOD
echo "<table border='1' bgcolor='#3b5998' style='float:left; margin:20'>
<tr>
<th>First Period</th>
</tr>";
while($row = mysql_fetch_array($resultfirst))
{
echo "<tr>";
echo "<td>" . $row['StudentName'] . "</td>";
echo "</tr>";
}
echo "</table>";
// 2nd PERIOD
echo "<table border='1' bgcolor='#3b5998' style='float:left; margin:20'>
<tr>
<th>Second Period</th>
</tr>";
while($row = mysql_fetch_array($resultsecond))
{
echo "<tr>";
echo "<td>" . $row['StudentName'] . "</td>";
echo "</tr>";
}
echo "</table>";
// 3rd PERIOD
echo "<table border='1' bgcolor='#3b5998' style='float:left; margin:20'>
<tr>
<th>Third Period</th>
</tr>";
while($row = mysql_fetch_array($resultthird))
{
echo "<tr>";
echo "<td>" . $row['StudentName'] . "</td>";
echo "</tr>";
}
echo "</table>";
// 4th PERIOD
echo "<table border='1' bgcolor='#3b5998' style='float:left; margin:20'>
<tr>
<th>Fourth Period</th>
</tr>";
while($row = mysql_fetch_array($resultfourth))
{
echo "<tr>";
echo "<td>" . $row['StudentName'] . "</td>";
echo "</tr>";
}
echo "</table>";
// 5th PERIOD
echo "<table border='1' bgcolor='#3b5998' style='float:left; margin:20'>
<tr>
<th>Fifth Period</th>
</tr>";
while($row = mysql_fetch_array($resultfifth))
{
echo "<tr>";
echo "<td>" . $row['StudentName'] . "</td>";
echo "</tr>";
}
echo "</table>";
If the code above is unclear- my goal is to compare the first period teachers in which are stored in the database, and output the students names that share the same period/teacher.
This code works fine. But the tables look very bland. I would like to echo the data into a table such as this.
<table width="368" border="0" cellspacing="0" cellpadding="2" align="center" height="100">
<tr valign="middle">
<td bgcolor="#000066" width="120" height="20">
<div align="center"><font color="#FFFFFF"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Web
Services</font></b></font> </div>
</td>
<td width="4" height="20"></td>
<td bgcolor="#990000" width="120" height="20">
<div align="center"><font color="#FFFFFF"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Web
Products</font></b></font></div>
</td>
<td width="4" height="20"></td>
<td bgcolor="#C89800" width="120" height="20">
<div align="center"><font color="#FFFFFF"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Web
Resources</font></b></font> </div>
</td>
</tr>
<tr valign="top">
<td bgcolor="#000066" width="120">
<table width="100%" border="0" cellspacing="0" cellpadding="3" height="80">
<tr bgcolor="#FFFFFF" valign="top">
<td>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="1">Professional
and cost effective web design, development and promotion services
</font></p>
</td>
</tr>
</table>
</td>
<td width="4"></td>
<td bgcolor="#990000" width="120">
<table width="100%" border="0" cellspacing="0" cellpadding="3" height="80">
<tr bgcolor="#FFFFFF" valign="top">
<td>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="1">Interactive
Web Products - Flash Survey, poll, Guest book, Instant Quote
</font></p>
</td>
</tr>
</table>
</td>
<td width="4"></td>
<td bgcolor="#C89800" width="120">
<table width="100%" border="0" cellspacing="0" cellpadding="3" height="80">
<tr bgcolor="#FFFFFF" valign="top">
<td>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="1">Free
web resources - articles, tutorials, tips and tricks.
</font></p>
</td>
</tr>
</table>
</td>
</tr>
</table>
If anyone can offer any suggestions of any sort- I would greatly appreciate it.
I see a few areas that can be improved:
As others have said, don't use tables to manage layout. However, tables are perfectly acceptable for displaying tabular data
You really want to use CSS to style your page, it's a lot easier to control your style and makes the markup easier to read. See this w3schools' artcile on CSS Tables
You can combine your multiple queries into one for better performance (though, that seems to be outside the scope of your question)
Here is an example markup and CSS for your table: http://jsfiddle.net/vxzJV/

Categories