kemper Posted July 14, 2007 Share Posted July 14, 2007 I am displaying my alignments, as coded below. I have 35 different divisions in f07div field of table. My current display is a long list with no clear break for change in f07div. How can I change my display to show teams if each division within into own table? Something like: Division A Division B Team 1 Team 1 Team 2 Team 2 Team 3 Team 3 Team 4 Team 4 Team 5 Team 5 Division C Team 1 etc. <?php require_once "maincore.php"; require_once "subheader.php"; require_once "side_left.php"; include LOCALE.LOCALESET."reg.php"; if ($step == "view") { if (!$id|| !isNum($id)) opentable ("Fall 2007"); $data = dbarray(dbquery( "SELECT ter.*, user_id,user_name FROM f2007_registrations ter LEFT JOIN ".$db_prefix."users tusr ON ter.reg_user=tusr.user_id WHERE id='".$id."'" )); echo "<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'> <tr> <td colspan='2' class='tbl2' valign='top'><font size='3'><b>".$data['age']."</b> playing in the <b>".$data['f07div']."</b> Division</font></td> </tr> <tr> <td width='19%' class='tbl2' valign='top'><b>Team Name:</b></td> <td class='tbl1' width='81%' valign='top'>".$data['Team']."</td> </tr> <tr> <td width='19%' class='tbl2' valign='top'><b>Club:</b></td> <td class='tbl1' width='81%' valign='top'>".$data['Other_Club']." (".$data['Club'].")</td> </tr> <tr> <td width='19%' class='tbl2' valign='top'><b>Team Administrators:</b></td> <td class='tbl1' width='81%' valign='top'> <table border='0' cellpadding='0' cellspacing='0' width='100%' id='table1'> <tr> <td width='50%'>".$data['Coach']." - <font color='#0000ff'>Coach</font></td> <td width='50%'>".$data['Manager']." - <font color='#0000ff'>Manager</font></td> </tr> <tr> <td width='50%'>".$data['Coach_Phone']."</td> <td width='50%'>".$data['Manager_Phone']."</td> </tr> <tr> <td width='50%'><a href='mailto:".$data['Coach_email']."'>".$data['Coach_email']."</a></td> <td width='50%'><a href='mailto:".$data['Manager_email']."'>".$data['Manager_email']."</a></td> </tr> </table> </td> </tr> <tr> <td width='19%' class='tbl2' valign='top'><b>Home Field:</b></td> <td class='tbl1' width='81%' valign='top'>".$data['Field']."</td> </tr> <tr> <td width='19%' class='tbl2' valign='top'><b>Conflicts (X):</b></td> <td class='tbl1' width='81%' valign='top'> <table border='0' cellpadding='0' cellspacing='0' width='300' id='table2'> <tr> <td width='25'><b><font color='#FF0000'>".$data['Sept8']."</font></b></td> <td width='125'>Saturday, Sept 8</td> <td width='25'><b><font color='#FF0000'>".$data['Sept9']."</font></b></td> <td width='125'>Sunday, Sept 9</td> </tr> <tr> <td width='25'><b><font color='#FF0000'>".$data['Sept15']."</font></b></td> <td width='125'>Saturday, Sept 15</td> <td width='25'><b><font color='#FF0000'>".$data['Sept16']."</font></b></td> <td width='125'>Sunday, Sept 16</td> </tr> <tr> <td width='25'><b><font color='#FF0000'>".$data['Sept22']."</font></b></td> <td width='125'>Saturday, Sept 22</td> <td width='25'><b><font color='#FF0000'>".$data['Sept23']."</font></b></td> <td width='125'>Sunday, Sept 23</td> </tr> <tr> <td width='25'><b><font color='#FF0000'>".$data['Sept29']."</font></b></td> <td width='125'>Saturday, Sept 29</td> <td width='25'><b><font color='#FF0000'>".$data['Sept30']."</font></b></td> <td width='125'>Sunday, Sept 30</td> </tr> <tr> <td width='25'><b><font color='#FF0000'>".$data['Oct6']."</font></b></td> <td width='125'>Saturday, Oct 6</td> <td width='25'><b><font color='#FF0000'>".$data['Oct7']."</font></b></td> <td width='125'>Sunday, Oct 7</td> </tr> <tr> <td width='25'><b><font color='#FF0000'>".$data['Oct13']."</font></b></td> <td width='125'>Saturday, Oct 13</td> <td width='25'><b><font color='#FF0000'>".$data['Oct14']."</font></b></td> <td width='125'>Sunday, Oct 14</td> </tr> <tr> <td width='25'><b><font color='#FF0000'>".$data['Oct20']."</font></b></td> <td width='125'>Saturday, Oct 20</td> <td width='25'><b><font color='#FF0000'>".$data['Oct21']."</font></b></td> <td width='125'>Sunday, Oct 21</td> </tr> <tr> <td width='25'><b><font color='#FF0000'>".$data['Oct27']."</font></b></td> <td width='125'>Saturday, Oct 27</td> <td width='25'><b><font color='#FF0000'>".$data['Oct28']."</font></b></td> <td width='125'>Sunday, Oct 28</td> </tr> </table> </td> </tr> <tr> <td width='19%' class='tbl2' valign='top'><b>Date of Registration Submission:</b></td> <td class='tbl1' width='81%' valign='top'><font color='#0000ff'>".$data['datestamp']."</font></td> </tr> <tr> <td width='19%' class='tbl2' valign='top'><b>Amount Owed:</b></td> <td class='tbl1' width='81%' valign='top'>$ ".$data['owed']."</td> </tr> <tr> <td width='19%' class='tbl2' valign='top'><b>Amount Paid:</b></td> <td class='tbl1' width='81%' valign='top'>$ ".$data['paid']."</td> </tr> </table>\n"; closetable(); tablebreak(); } opentable ("Fall 2007 Alignments"); echo"<p align='center'><strong><font face='Arial' size='5'>Fall 2007 Registered Teams</font></strong></p> <div align='center'> <table border='2' width='90%' id='table1' cellspacing='0' cellpadding='2' bordercolor='#FF0000'> <tr> <td bgcolor='#FFFF00' style='border-style: solid; border-width: 1px'> <p align='center'><font face='Arial' size='3'>These Alignments are subject to change and without notice.<br><br>Teams will not be written into the schedules until their fees have been paid in full.<br><br> Any questions, including whether payment has been received, should be directed to your League Director.</font></td> </tr> </table> </div><br>"; $sql = dbquery( "SELECT ter.*, user_id,user_name FROM f2007_registrations ter LEFT JOIN ".$db_prefix."users tusr ON ter.reg_user=tusr.user_id ORDER BY f07div 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%'> </td> <td class='tbl2' width='45%'> </td> <td align='center' class='tbl2' width='15%'><b>Fees<br> Owed:</b></td> <td align='center' class='tbl2' width='15%'><b>Amount<br> Paid:</b></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['f07div']."</font></td> <td class='$tclass' width='45%'> <a href='".FUSION_SELF."?step=view&id=".$data['id']."'><font size='1'>".$data['Team']."</font></a></td> <td align='center' class='$tclass' width='15%'>$ <font size='1'>".$data['owed']."</font></td> <td align='center' class='$tclass' width='15%'><b>$<font color='#0000FF' size='1'> ".$data['paid']."</b></font></td> </tr>\n"; } echo "</table>\n"; } else { echo "<center><br>\n".$locale['reg141']."<br><br>\n</center>\n"; } closetable(); require_once "side_right.php"; require_once BASEDIR."footer.php"; ?> Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 14, 2007 Share Posted July 14, 2007 that was har because when you echo the other data it will fall on the second row and second column so it wont have that alignment right? i would suggest put three query for each column and put then inside the loop having the if condition you may need or you can use the group by clause group the record by team so you will have it organize Quote Link to comment Share on other sites More sharing options...
kemper Posted July 14, 2007 Author Share Posted July 14, 2007 I am not quite following you. Quote Link to comment Share on other sites More sharing options...
kemper Posted July 14, 2007 Author Share Posted July 14, 2007 To clarrify also... I do not need to display Fees Owed, nor Fees Paid. Quote Link to comment Share on other sites More sharing options...
JayBachatero Posted July 14, 2007 Share Posted July 14, 2007 This should do what you want to do. Just need to modify the query to make it work with the correct tables. <?php // Get the data from the database. $request = mysql_query(" SELECT reg.f07div AS division, reg.id, reg.Team FROM f2007_registrations AS reg") or die(mysql_error()); // Now loop through the results and save into an array. $divisions = array(); while ($row = mysql_fetch_assoc($request)) { // Set a clean name for the keys. $division_name = strtolower(str_replace(array(' ', '-'), '_', $row['division'])); $divisions[$division_name]['name'] = $row['division']; // We must store the teams this way in the array. $divisions[$division_name]['teams'][$row['id']] = array( 'id' => $row['id'], 'name' => $row['Team'], ); } // Now loop through each division and then loop through the teams. $columnBreak = true; echo ' <table>'; foreach ($divisions as $division) { // Open the tr. if ($columnBreak == true) echo ' <tr>'; // No for the division name. echo ' <td> <table> <tr> <th>' . $division['name'] . '</th> </tr>'; // Loop through the teams now for this division. foreach ($division['teams'] as $team) echo ' <tr> <td>' . $team['name'] . '</td> </tr>'; // Close the table and td. echo ' </table> </td>'; // Close the row? if ($columnBreak == false) echo ' </tr>'; // Negate it. $columnBreak = !$columnBreak; } // Do we have an empty row? if ($columnBreak == false) echo ' <td> </td> </tr>'; echo ' </table>'; ?> Quote Link to comment 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.