Jump to content

[SOLVED] display breaks in table classifications


kemper

Recommended Posts

If my table has a structure like:

Division Team
A Team 1
A Team 2
A Team 8
A Team 9
B Team 3
B Team 4
B Team 6
B Team 7

 

How can I change my script of:

<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'>
<tr>
<td class='tbl2'><b>Division</b></td>
<td class='tbl2'><b>Team</b></td>
</tr>\n";
while ($data = dbarray($sql)) {
	$i % 2 == 0 ? $tclass="tbl1" : $tclass="tbl2";
	echo "<tr>
<td class='$tclass'><font size='1'>".$data['f07div']."</font></td>
<td class='$tclass'>
<font size='1'>".$data['Team']."</font></td>
</tr>\n";
}
echo "</table>

To display some type of break between each division?

Link to comment
Share on other sites

<?php 
echo "<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'>
<tr>
<td class='tbl2'><b>Division</b></td>
<td class='tbl2'><b>Team</b></td>
</tr>\n";

$prev = '';
while ($data = dbarray($sql)) {
    $tclass = $i % 2 == 0 ? "tbl1" : "tbl2";
    if ($data['f07div'] != $prev) {                                // if division changed
        echo "<tr><td colspan='2'> </td></tr>\n";             // blank row
        $prev = $data['f07div'];
    }
    echo "<tr>
    <td class='$tclass'><font size='1'>".$data['f07div']."</font></td>
    <td class='$tclass'>
    <font size='1'>".$data['Team']."</font></td>
    </tr>\n";
}
echo "</table>\n"

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.