Jump to content

Do I need multiple queries to do what I'm doing?


Jim R

Recommended Posts

The whole code is below, followed by the part that isn't producing.  It all works extremely well until the last part, and I have two instances of setting a variable to mysql_fetch_assoc that work.  Not sure why the third attempt doesn't.  I'm just trying to have a separate area that outputs 'msg'.

 


$sql = "SELECT * FROM players as p 
INNER JOIN schools as s
WHERE p.tid = s.id
ORDER BY status, playerLast";

$results = mysql_query($sql);



echo '<div class="roster">';

$team = mysql_fetch_assoc($results);

echo '<div class="team_info">
<div class="school">' . $team['school'] . '</div>
<div class="coach">Coach ' .$team['coachFirst'] . ' ' . $team['coachLast'] .'</div>
<div>Sectional: ' . $team['sectional'] . '</div>
<div>Class: ' . $team['class'] . 'A</div>
';

echo '</div>';


  $currentStatus = false;  //Flag to detect change in status
    while($player = mysql_fetch_assoc($results))
    {


        if($currentStatus != $player['status'])
        {
            //Status has changed, display status header
            $currentStatus = $player['status'];
		echo '<br><b>';
	if ($currentStatus == '1')  {echo 'Returning Starters';}
	elseif ($currentStatus == '2')  {echo 'Key Returners';}
	elseif ($currentStatus == '3')  {echo 'Varsity Newcomers';}
	elseif ($currentStatus == '4')  {echo 'Key Freshmen';}
		echo '</b><br>';
           // echo "<div><b>{$currentStatus}</b></div>\n";
        }
        //Display player info
        echo $player['playerFirst'] . ' ' . $player['playerLast'] . ', ' . $player['feet'] . '\'' . $player['inches'] . '",' . $player['position'] . ', ' . $player['year'] . ';<br>';

    }

        //Player comments
echo '<hr>';
echo '<div class="coach_comments"><span class="player_name">hello';

while($comments = mysql_fetch_assoc($results)) {


	echo $comments['playerFisrt'] . ' ' . $comments['playerLast'] . ':  </span>' . $comments['msg'];
}
echo '</div>';
echo '</div>';

 

 

It's all working until what's below.  All I get out of it is the "hello", which is just a test to make sure it wasn't a CSS issue.

 

 

        //Player comments

echo '<hr>';

echo '<div class="coach_comments"><span class="player_name">hello';

 

while($comments = mysql_fetch_assoc($results)) {

 

 

echo $comments['playerFisrt'] . ' ' . $comments['playerLast'] . ':  </span>' . $comments['msg'];

}

echo '</div>';

echo '</div>';

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.