Jump to content

[SOLVED] Display Error (Group name appears as 'Unrevealed')


Recommended Posts

Hello one and all.

  I'm trying to build a small 3 columned display which will state the name  of a group (Alpha, Beta, etc), and those in each group. Currently, the names all line up and display to each corresponding group, but the group name itself displays as 'unrevealed'  vs. 'Alpha', 'Beta' etc.

 

Additionally have weird spacing before and after each group rather then them all lining up nice and neat. Any help is always apprecaited! (i'll move yoda aside and build a shrine to you on my bedroom dresser ;) thanks as always:

<TR>
<TD COLSPAN="3" align="left">

<?php
// Student Squadrons

$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);

$thisID = $advisee["id"];
$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>

 

 

So I tried revising the lines #61 through #67 and received the following error which is at the very end of the code (Line #129 is the final line of code):

Parse error: parse error, unexpected $ in /home/content/z/a/n/zanland/html/xpg/institute/institute3.1.php on line 129

 

This is the code I tried applying (another person suggested it, and once i figured out it had special hidden code characters and stripped those out i was able to move pass the odd t-string error i was getting to the new odd parsing error :(

 

New lines #61 - 67:

	$group = '';
while ($row = mysql_fetch_assoc($result)) {
if ($group !== $row['user_group']) {
	 $group = $row['user_group'];
	echo '<h3>' . $group . '</h3>';
}

 

 

Full revised code:

<TR>
<TD COLSPAN="3" align="left">

<?php
// Student Squadrons

$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;

$group = '';
while ($row = mysql_fetch_assoc($result)) {
if ($group !== $row['user_group']) {
	 $group = $row['user_group'];
	echo '<h3>' . $group . '</h3>';
}
// roll out rows

WHILE ($advisee = mysql_fetch_assoc($result)) {

$thissquadronDBID = $advisee["squadronDB"];
$squadronDBRealName = getRealName($thissquadronDBID);

$thisID = $advisee["id"];
$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>


</TABLE>

 

 

Any help  will have me sacrificing twinkee's in your name tonight at midnight at PST

 

Hi,

 

Firstly - about your new section of code - I cant see what it is doing.

 

You are comparing $row to $row['user_group'] but you do not pull back a user_group field in your SQL query??

 

As for your original question can I see the getRealName Function?

 

$squadronDBRealName = getRealName($thissquadronDBID);

Hello PHP_Dave.

  I'm not sure of what I'm doing honestly. I'm really new to all of this stuff. I'm trying to resolve the problem as displayed by going to this url http://www.xpg.us/institute/institute3.0.php As you can see the names of  each group show as 'unrevealed'. I'm working with some old code i have and trying to modify/repurpose it. And it's working accept that it's not revealing the names of the actual teams :(

 

As to what the new code is doing -- i'm not sure either but it was suggested i try it so I'm trying it.

 

getRealName Function (i listed all my get functions to be safe):

function getName ($id) {
$myLogin = readDatabase("select username from login WHERE id=\"$id\"");
if (!$myLogin["username"]) { return "-Deleted User-"; } else { return $myLogin["username"]; }
} // end FUNCTION

function getEmail ($player) {
$myLogin = readDatabase("select email from login WHERE id=\"$player\"");
if ($myLogin["email"]) { return $myLogin["email"]; }
} // end FUNCTION

function getChar ($id) {
$myLogin = readDatabase("select codename from cerebra WHERE id=\"$id\"");
if (!$myLogin["codename"]) { return "Storyteller"; } else { return $myLogin["codename"]; }
} // end FUNCTION

function getSquad ($id) {
$myLogin = readDatabase("select squadronDB from cerebra WHERE id=\"$id\"");
return $myLogin["squadronDB"];
} // end FUNCTION

function getLocation($id) {
$myLogin = readDatabase("select name from locations WHERE id=\"$id\"");
return $myLogin["name"];
} // end FUNCTION

function getAllChars($id) {
$theseChars=array();
if ($id) {
$myLogin = mysql_query("select codename from cerebra WHERE player=$id");
WHILE ($codename = mysql_fetch_assoc($myLogin)) { array_push($theseChars, $codename["codename"]); }
} // end if ID
return $theseChars;
} // end FUNCTION

function getRealName ($id) {
$myLogin = readDatabase("select name from cerebra WHERE id=\"$id\"");
if (!$myLogin["name"]) { return "(Unrevealed)"; } else { return $myLogin["name"]; }
} // end FUNCTION

function getModelName ($id) {
$myLogin = readDatabase("select name from cerebra WHERE id=\"$modelname\"");
if (!$myLogin["modelname"]) { return "(Unrevealed)"; } else { return $myLogin["modelname"]; }
} // end FUNCTION

function getThreadName($id) {
$myLogin = readDatabase("select subject from board WHERE thread=\"$id\" ORDER BY dateadded LIMIT 1");
return $myLogin["subject"];
} // end FUNCTION

function getPost($id) {
$myPost = readDatabase("select * from board WHERE id=\"$id\" LIMIT 1");
return $myPost;
} // end FUNCTION

function getSubject($id) {
$myLogin = readDatabase("select subject from board WHERE id=\"$id\" LIMIT 1");
return $myLogin["subject"];
} // end FUNCTION

function checkOOC($thread) {

if (!$thread) { return false; }
$myLogin = readDatabase("select charid,storyteller from board WHERE thread=\"$thread\" ORDER BY dateadded LIMIT 1");
if ($myLogin["charid"]!=0  || $myLogin["storyteller"]) { return false; } else { return true; }
} // end FUNCTION

 

 

Old code i'm repurposing You can see the effects of this code by going to http://www.xpg.us/institute/institute.php:

<?php
// STUDENT ADVISORS

$sql = "SELECT id, advisor FROM cerebra WHERE approved=\"true\" AND advisor IS NOT NULL AND advisor != \"\" AND type=\"student\" AND player > 0 ORDER BY advisor";
$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 cellpadding='0'><tr>";

$currentAdvisor = "";
$col = 0;

WHILE ($advisee = mysql_fetch_assoc($result)) {

$thisAdvisorID = $advisee["advisor"];
$advisorRealName = getRealName($thisAdvisorID);
$advisorCodeName = getChar($thisAdvisorID);
$advisorCodeName = preg_replace("/\"/", """, $advisorCodeName);
$advisorRealName = preg_replace("/\"/", """, $advisorRealName);
if ($advisorRealName == "(Unrevealed)") { $advisorRealName = $advisorCodeName; }

$thisID = $advisee["id"];
$realName = getRealName($thisID);
$codeName = getChar($thisID);
$codeName = preg_replace("/\"/", """, $codeName);
$realName = preg_replace("/\"/", """, $realName);
if ($realName == "(Unrevealed)") { $realName = $codeName; }


if ($thisAdvisorID != $currentAdvisor) {
if ($col == 5) { echo "</td><td width='25'></td>\n"; $col=0; }
if ($col == 0) { echo "<td valign='top'>"; }
echo "\n\n<!-- COL: $col -->\n\n";
if ($currentAdvisor && $col > 0) { echo "</p>\n\n"; }
echo "<p><a href=\"/cerebra/display.php?id=$thisAdvisorID\" title=\"$advisorCodeName\"><font color='white'>$advisorRealName</font></a><br>\n";
$col++;
} // end if new advisor subheader

echo "<span class='fineprint'><a href=\"/cerebra/display.php?id=$thisID\" title=\"$codeName\">$realName</a></span><br>\n";

$currentAdvisor = $thisAdvisorID;

} // end WHILE

IF ($col < 5) { echo "</td>"; }

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


 

Hi mate,

 

This query

$sql = "SELECT id, squadronDB FROM cerebra WHERE approved=\"true\" AND squadronDB IS NOT NULL AND squadronDB != \"\" AND type=\"student\" ORDER BY squadronDB";

 

what does squadronDB return?  is it a number or ALPHA, BETA?

Hey,

 

You shouldnt be calling the realname function as this only returns the field "name" from cerebra.. change this

 

$thissquadronDBID = $advisee["squadronDB"];
$squadronDBRealName = getRealName($thissquadronDBID);

 

to this

 

$squadronDBRealName = $advisee["squadronDB"];

 

And your Squad names should display as intended.

Hello PHP_Dave,

  Thank you for the suggestion, I attempted it as you can http://www.xpg.us/institute/institute3.3.php, unfortunately the results were not what was intended as all the headers went away rather listing as the team. I believe the information is there for if you click on the reveals, the headers try to send you to the team/squadrons individual group page (which i've not yet built) http://www.xpg.us/institute/institute3.2.php

 

Any other ideas, suggestions or thoughts?

And thanks for the suggestions and help thus far - your really kind to help a newb like myself. I very very much appreciated and sacrificed a twinkie last night in your name (it was actually a ding dong).

 

Thanks!

My goal was to display the names of the teams, and then the members of the teams. The page i've built does all of these things now thanks to PHP_dave who pointed me in the right course which was to look at my functions, not my php. I replaced the getRealName function with a new function called 'getSquadName' .

 

I still have an issue as their is an odd bug in my php function still, but it's doing what I want so this is solved - thanks!

 

Original function:

function getRealName ($id) {

$myLogin = readDatabase("select name from cerebra WHERE id=\"$id\"");

if (!$myLogin["name"]) { return "(Unrevealed)"; } else { return $myLogin["name"]; }

} // end FUNCTION

 

New function

function getSquadName ($id) {

$myLogin = readDatabase("select squadronDB from cerebra WHERE id=\"$id\"");

if (!$myLogin["squadronDB"]) { return " \"$id\""; } else { return $myLogin["squadronDB"]; }

} // end FUNCTION

Uhm.... no... I don't even know what any of what you said means  :'( I was just happy i could make my thing work. If you know of a better way, please illuminate my ears! I'm a complete novice and i'm just doing what i can based on whatever things i can manage to connect so that the elements work. So, to recap:

I'm a newb.

and 'Huh?'

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.