Chezshire Posted August 15, 2008 Share Posted August 15, 2008 Hi everyone, So i'm working on my little thing as always, and i got pretty far with my newest attempt, but after a few hours i thought it best to reach out to those who know vs. me who don't I want the names of each group to show, then underneath each group name, all members of that group to display. Right now all the names of the people belong to a group display, but the name of the group doesn't. Can anyone help me? thanks <TD COLSPAN="3" align="left"> <?php // STUDENT ADVISORS $sql = "SELECT id, squadronDB FROM cerebra WHERE approved=\"true\" AND squadronDB IS NOT NULL AND squadronDB != \"\" AND type=\"student\" AND player > 0 ORDER BY squadronDB"; $result = mysql_query($sql); echo "<br>\n<h2><font color='#A5B9D5'>STUDENT ADVISORS</font></h2>\n"; echo "<hr color='#050F1D' size='5'>\n"; echo "<table width='100%' cellpadding='0'>"; $currentSquadronDB = ""; $isInitial = 0; $squadronDBNumber = 0; WHILE ($advisee = mysql_fetch_assoc($result)) { $thissquadronDBID = $advisee["squadronDB"]; $squadronDBRealName = getRealName($thissquadronDBID); $squadronDBCodeName = getChar($thissquadronDBID); $squadronDBCodeName = preg_replace("/\"/", """, $squadronDBCodeName); $squadronDBRealName = preg_replace("/\"/", """, $squadronDBRealName); $thisID = $advisee["id"]; $realName = getRealName($thisID); $codeName = getChar($thisID); $codeName = preg_replace("/\"/", """, $codeName); $realName = preg_replace("/\"/", """, $realName); if ($thissquadronDBID != $currentsquadronDB) { // Close previous column if ($isInitial != 0) { echo '</div>'; echo '</td>'; } // close previous row and reset squadron number for the new row if ($squadronDBNumber == 3) { echo "</tr>"; $squadronDBNumber = 1; } else { // Increase squadronDB number $squadronDBNumber++; } // start a new row if ($squadronDBNumber == 1) { echo "<tr>"; } // open column echo '<td width="33%">'; // create div echo '<div style="float: left; padding-top: 5; padding-left: 5;">'; // Place squadronDB's name echo "<p><a href=\"/cerebra/display.php?id=$thissquadronDBID\" title=\"$squadronDBCodeName\"><font color='white'>$squadronDBRealName</font></a></p>"; $isInitial = 1; } // end if new advisor subheader // enter student echo "<span class='fineprint'><a href=\"/cerebra/display.php?id=$thisID\" title=\"$codeName\">$realName</a></span><br>\n"; // Make the current advisor this advisor $currentsquadronDB = $thissquadronDBID; } // end WHILE echo "</table>"; ?> </TD> Quote Link to comment https://forums.phpfreaks.com/topic/119787-display-issue-group-type-doesnt-show-but-space-for-them-does/ Share on other sites More sharing options...
ignace Posted August 15, 2008 Share Posted August 15, 2008 $group = ''; while ($row = mysql_fetch_assoc($result)) { if ($group !== $row['user_group']) { $group = $row['user_group']; echo '<h3>' . $group . '</h3>'; } // roll out rows.. Quote Link to comment https://forums.phpfreaks.com/topic/119787-display-issue-group-type-doesnt-show-but-space-for-them-does/#findComment-617219 Share on other sites More sharing options...
Chezshire Posted August 15, 2008 Author Share Posted August 15, 2008 THank you Ignace for the assistance - I'm not sure where this goes within my code - I've tried a few places and the result is always a T string error. Can you provide further help and or guidance? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/119787-display-issue-group-type-doesnt-show-but-space-for-them-does/#findComment-617714 Share on other sites More sharing options...
Chezshire Posted August 16, 2008 Author Share Posted August 16, 2008 I'm not sure where to place the suggested code - when i tired it in various spots i got t-string errors. Can you tell me where it goes/replaces? Also i have weird/odd gaps after and before the groups that make no sense. <TR> <TD COLSPAN="3" align="left"> <?php // STUDENT ADVISORS $sql = "SELECT id, squadronDB FROM cerebra WHERE approved=\"true\" AND squadronDB IS NOT NULL AND squadronDB != \"\" AND type=\"student\" ORDER BY squadronDB"; $result = mysql_query($sql); echo "<br>\n<h2><font color='#A5B9D5'>SQUADRONS 2</font></h2>\n"; echo "<hr color='#050F1D' size='5'>\n"; echo "<table width='100%' cellpadding='0'>"; $currentSquadronDB = ""; $isInitial = 0; $squadronDBNumber = 0; WHILE ($advisee = mysql_fetch_assoc($result)) { $thissquadronDBID = $advisee["squadronDB"]; $squadronDBRealName = getRealName($thissquadronDBID); $squadronDBCodeName = getChar($thissquadronDBID); $squadronDBCodeName = preg_replace("/\"/", """, $squadronDBCodeName); $thisID = $advisee["id"]; $realName = getRealName($thisID); $codeName = getChar($thisID); $codeName = preg_replace("/\"/", """, $codeName); if ($thissquadronDBID != $currentsquadronDB) { // Close previous column if ($isInitial != 0) { echo '</div>'; echo '</td>'; } // close previous row and reset squadron number for the new row if ($squadronDBNumber == 3) { echo "</tr>"; $squadronDBNumber = 1; } else { // Increase squadronDB number $squadronDBNumber++; } // start a new row if ($squadronDBNumber == 1) { echo "<tr>"; } // open column echo '<td width="33%">'; // create div echo '<div style="float: left; padding-top: 5; padding-left: 5;">'; // Place squadronDB's name echo "<p><a href=\"/cerebra/display.php?id=$thissquadronDBID\" title=\"$squadronDBID\"><font color='white'>$squadronDBRealName</font></a></p>"; $isInitial = 1; } // end if new squadron subheader // enter student(s) echo "<span class='fineprint'><a href=\"/cerebra/display.php?id=$thisID\" title=\"$codeName\">$codeName</a></span><br>\n"; // Make the current advisor this advisor $currentsquadronDB = $thissquadronDBID; } // end WHILE echo "</table>"; ?> </TD> </TR> Quote Link to comment https://forums.phpfreaks.com/topic/119787-display-issue-group-type-doesnt-show-but-space-for-them-does/#findComment-617770 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.