Jump to content

Table Display grouped by specific field


kemper

Recommended Posts

I operate a youth sports website and i display my current alignments in a long running list of teams (one field within my table) with association divisions (another field within table).

 

I would like to group them by divisions, like a two column table for better clarification.

 

Example:

Division 1

Division 2

Team 1[br]Team 2[br]Team 3[br]Team 4[br]Team 5

Team 1[br]Team 2[br]Team 3[br]Team 4

[br][br]

Division 3

Division 4

Team 1[br]Team 2[br]Team 3[br]Team 4

Team 1[br]Team 2[br]Team 3[br]Team 4[br]Team 5

[br][br]

 

How do I modify my code???

 

$sql = dbquery(
"SELECT ter.*, user_id,user_name FROM s2008_registrations ter
LEFT JOIN ".$db_prefix."users tusr ON ter.reg_user=tusr.user_id
ORDER BY s08div ASC, team ASC"
);
if (dbrows($sql)) {
$i = 0;
echo "<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'>
<tr>
<td class='tbl2' width='25%'>Division</td>
<td class='tbl2' width='45%'>Team Name</td>
</tr>\n";
while ($data = dbarray($sql)) {
	$i % 2 == 0 ? $tclass="tbl1" : $tclass="tbl2";
	echo "<tr>
<td class='$tclass' width='25%'><font size='1'>".$data['s08div']."</font></td>
<td class='$tclass' width='45%'>
<a href='".FUSION_SELF."?step=view&id=".$data['id']."'><font size='1'>".$data['team']."</font></a></td>

</tr>\n";
}
echo "</table>

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.