Jump to content

Display Issue (Group type doesn't show but space for them does)


Chezshire

Recommended Posts

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>

 

 

 

 

 

$group = '';

while ($row = mysql_fetch_assoc($result)) {

    if ($group !== $row['user_group']) {

        $group = $row['user_group'];

        echo '<h3>' . $group . '</h3>';

    }

    // roll out rows..

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>

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.