title: I want to get all players with a team name given
body: <p>I will get team_name from previous page and then I want to show all the players with that team name in the browser. 
  But it gives error and when I try to print variable <code>$players</code> it has only details of one player with that team name.
  I think the result of query must be stored in some kind of 2-D array but I am not able to think the logic behind it.</p>
  
  <p>Player Table has attributes</p>
  
  <ul>
  <li>player_name</li>
  <li>jearsy_no  </li>
  <li>team_name  </li>
  <li>phone_no  </li>
  <li>dob</li>
  </ul>
  
  <pre><code>&lt;?php 
   include('config/db_connect.php');
   if(isset($_GET['team_name'])) {
    $team_name = mysqli_real_escape_string($conn, $_GET['team_name']);
    $sql_players = "SELECT * FROM player WHERE team_name = '$team_name'";
    $result_players = mysqli_query($conn, $sql_players);
    $players = mysqli_fetch_assoc($result_players);
    //print_r($players);
   }   
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;?php include('templates/header.php'); ?&gt;
  
    &lt;?php foreach($players as $player) : ?&gt; 
    &lt;div class="container"&gt;
          &lt;h6&gt;&lt;?php echo htmlspecialchars($player['player_name']); ?&gt;&lt;/h6&gt;
    &lt;/div&gt;
    &lt;?php endforeach; ?&gt;
  
  &lt;?php include('templates/footer.php'); ?&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>Warning: Illegal string offset 'player_name'</p>
  </blockquote>
  
  <p>And when I try to <code>print_r($players)</code> I get: </p>
  
  <pre><code>  Array ( [player_name] =&gt; Dwayn Miller 
            [jearsy_no] =&gt; 32 
            [team_name] =&gt; Team Australia 
            [dob] =&gt; 1998-12-11 
            [player_phone] =&gt; 4009871234 
          )
  </code></pre>