|
|
#1 (permalink) |
|
Registered User
Fresh Surpasser
Joined in Aug 2003
Hosted on D19
7 posts
Gave thanks: 1
Thanked 0 times
|
Hello all,
I'm stuck! This is the page I am dealing with: http://www.rscfleet.net/roster/index.php With it being the first PHP script I have ever done, I was feeling rather good about myself that everything looked to be in order; I even managed to create a functional Admin panel! However... There is a problem with the 'Command Staff' and 'Officers' separators. While they are displayed in the correct location, they have also replaced the member who should be shown beneath them. As a result, I am missing the first member under 'Command Staff', and the first member under 'Officers'. Any ideas on how I might go about correcting this? I have pasted the full code below (please excuse the slopiness); Code:
<html>
<head>
<LINK REL="StyleSheet" HREF="css/roster.css" TYPE="text/css" MEDIA="screen">
<title>RSC Fleet Roster</title>
</head>
<body>
<?
/* Sets the variables for MySQL connection */
$server = "localhost";
$username = "*******";
$password = "*******";
/* Connects to the MySQL server */
$link = @mysql_connect ($server, $username, $password)
or die (mysql_error());
/* Defines the Active Database for the Connection */
if (!@mysql_select_db("*******", $link)) {
echo "<p>There has been an error. This is the error message:</p>";
echo "<p><strong>" . mysql_error() . "</strong></p>";
}
/* Retrieve roster count */
$rostercount = mysql_query("SELECT COUNT(*) as TOTALFOUND from Members", $link);
?>
<center>
<table class="maintable" cellpadding="2" cellspacing="5">
<tr>
<td class="tdfield" colspan="6">There are currently <b><?print (mysql_result($rostercount,0,"TOTALFOUND"));?></b> members.</td>
</tr>
<tr>
<td class="tdfield"><b>Alias</b></td>
<td class="tdfield"><b>Insignia</b></td>
<td class="tdfield"><b>Rank</b></td>
<td class="tdfield"><b>Position</b></td>
<td class="tdfield"><b>Divison(s)</b></td>
</tr>
<tr>
<td class="tdlabel" colspan="6"><b>Senate</b></td>
</tr>
<?
/* Retrieve Insignia images */
$i = 0;
$insignia_result = mysql_query("SELECT ID, ImageURL FROM Insignia", $link)
or die("Invalid query: " . mysql_error() . "<BR>");
while ($insignia_row = mysql_fetch_row($insignia_result))
{
$insignia[$insignia_row[0]] = $insignia_row[1];
$i++;
}
/* Retrieve Rank labels */
$i = 0;
$rank_result = mysql_query("SELECT ID, Name FROM Rank", $link)
or die("Invalid query: " . mysql_error() . "<BR>");
while ($rank_row = mysql_fetch_row($rank_result))
{
$rank[$rank_row[0]] = $rank_row[1];
$i++;
}
/* Retrieve Position labels */
$i = 0;
$position_result = mysql_query("SELECT ID, Name FROM Position", $link)
or die("Invalid query: " . mysql_error() . "<BR>");
while ($position_row = mysql_fetch_row($position_result))
{
$position[$position_row[0]] = $position_row[1];
$i++;
}
/* Retrieve Legacy status images */
$i = 0;
$legacy_result = mysql_query("SELECT ID, ImageURL FROM Legacy", $link)
or die("Invalid query: " . mysql_error() . "<BR>");
while ($legacy_row = mysql_fetch_row($legacy_result))
{
$legacy[$legacy_row[0]] = $legacy_row[1];
$i++;
}
/* Retrieve CSS status images */
$i = 0;
$css_result = mysql_query("SELECT ID, ImageURL FROM CSS", $link)
or die("Invalid query: " . mysql_error() . "<BR>");
while ($css_row = mysql_fetch_row($css_result))
{
$css[$css_row[0]] = $css_row[1];
$i++;
}
/* Retrieve RTW status images */
$i = 0;
$rtw_result = mysql_query("SELECT ID, ImageURL FROM RTW", $link)
or die("Invalid query: " . mysql_error() . "<BR>");
while ($rtw_row = mysql_fetch_row($rtw_result))
{
$rtw[$rtw_row[0]] = $rtw_row[1];
$i++;
}
$divided = false;
$divided2 = false;
$roster_result = mysql_query("SELECT ID, Alias, Insignia, Rank, Position, Legacy, CSS, RTW FROM Members ORDER BY Rank ASC, Position ASC, Insignia ASC, Alias ASC", $link)
or die("Invalid query: " . mysql_error() . "<BR>");
/* Retrieves the rows from the query result set and puts them into an HTML table row */
while ($roster_row = mysql_fetch_row($roster_result))
{
/* Divide Senate from Command Staff */
if ($divided == false && $roster_row[3] > 3)
{
$divided = true;
echo ("<tr>\n\t<td class=\"tdlabel\" colspan=\"6\"><b>Command Staff</b></td>\n</tr>\n");
}
/* Divide Command Staff from Officers */
elseif ($divided2 == false && $roster_row[4] > 5)
{
$divided2 = true;
echo ("<tr>\n\t<td class=\"tdlabel\" colspan=\"6\"><b>Officers</b></td>\n</tr>\n");
}
else {
echo "<tr>\n\t"
. "<td class=\"tdfield\">" . $roster_row[1] . "</td>"
. "<td class=\"tdfield\"><img src=\"ranks/" . $insignia[$roster_row[2]] . "\"></td>"
. "<td class=\"tdfield\">" . $rank[$roster_row[3]] . "</td>"
. "<td class=\"tdfield\">" . $position[$roster_row[4]] . "</td>"
. "<td class=\"tdfield\"><img src=\"games/" . $legacy[$roster_row[5]] . " \"> <img src=\"games/" . $css[$roster_row[6]] . " \"> <img src=\"games/" . $rtw[$roster_row[6]] . " \"></td>";
echo "\n</tr>\n"; }
}
/* Closes the table */
?>
</table>
<?
/* Closes Connection to the MySQL server */
mysql_close ($link);
?>
</table>
</center>
</body>
</html>
Last edited by LordUppity; October 27th, 2006 at 6:32 PM. |
|
|
|
|
|
#2 (permalink) |
|
Surpass Fan
Excelling Contributor
Joined in Nov 2005
Lives in Colorado
Hosted on DEDI
934 posts
Gave thanks: 2
Thanked 94 times
|
You are throwing away the data in the loop by using an if / elseif / else. It can only do one of three things. If think you want just this (remove the else part):
Code:
/* Divide Senate from Command Staff */
if ($divided == false && $roster_row[3] > 3)
{
$divided = true;
echo ("<tr>\n\t<td class=\"tdlabel\" colspan=\"6\"><b>Command Staff</b></td>\n</tr>\n");
}
/* Divide Command Staff from Officers */
elseif ($divided2 == false && $roster_row[4] > 5)
{
$divided2 = true;
echo ("<tr>\n\t<td class=\"tdlabel\" colspan=\"6\"><b>Officers</b></td>\n</tr>\n");
}
echo "<tr>\n\t"
. "<td class=\"tdfield\">" . $roster_row[1] . "</td>"
. "<td class=\"tdfield\"><img src=\"ranks/" . $insignia[$roster_row[2]] . "\"></td>"
. "<td class=\"tdfield\">" . $rank[$roster_row[3]] . "</td>"
. "<td class=\"tdfield\">" . $position[$roster_row[4]] . "</td>"
. "<td class=\"tdfield\"><img src=\"games/" . $legacy[$roster_row[5]] . " \"> <img src=\"games/" . $css[$roster_row[6]] . " \"> <img src=\"games/" . $rtw[$roster_row[6]] . " \"></td>";
echo "\n</tr>\n";
}
__________________
Where would you be if you were at the highest court in the land (US)? |
|
|
|
| These users thank cowboy for this great post! | Kayla (October 27th, 2006), LordUppity (October 27th, 2006) |