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

Link to comment
Share on other sites

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.