Error mysqli_fetch_assoc() expects Parameter 1 to be mysqli_result, Boolean Given in

Asked

Viewed 735 times

-1

I am creating a code in html and php where I see the error "mysqli_fetch_assoc() expects Parameter 1 to be mysqli_result, Boolean Given in ", this code will show scores for a minigolf tournament. the code gives me error in the code below.

<?php
        if($total){ do {
            $query1 = "SELECT nome from jogador WHERE nometeam = ".$linha['nometeam']; 
            $dados1 = mysqli_query($conn, $query1);
            $linha1 = mysqli_fetch_assoc($dados1);
print $query1
    ?>  

1 answer

0


There’s an error in code completion, try it like this.

<table class = "tabela" style="width:100%" border="0" bgcolor="white" style="text-align:center;">
<thead>
  <tr>
    <th>Equipa</th>
    <th>Jogador</th>
  </tr>
<tbody>
<?php
$query1 = "SELECT `equipa`,`nome` from `jogador` WHERE `nometeam` = '".$linha['nometeam']."'";

$dados1 = mysqli_query($conn, $query1);

while($linha1 = mysqli_fetch_array($dados1)){
  echo "<tr>";
  echo "<td>" . $linha1['equipa'] . "</td>";
  echo "<td>" . $linha1['nome'] . "</td>";
  echo "</tr>";
}
?>
</tbody>
</table>
  • It worked but look at the code of the whole table

  • Currently, only one player is presented to me by each team. I wanted to know how to introduce myself to 3 players per team?

  • Do you have 3 registrations (players) in your "team name" table? Because in while there is no restriction/result limit condition, while displays all, if you want to make a limitation you should add after WHERE nometeam = '".$line['nometeam']." ' LIMIT 3, for example.

  • yes, I have 3 players for 3 tables

  • If they are separate tables you should make the same code for each table, which is not recommended, the most correct would be for you to insert all players in the same table and differentiating only the type name with a "teamname" column, for example.

  • the name of the teams and the name of the players are on the same table(player table)

  • In the answer presented by me, the code will display all, maybe it is some limitation imposed on your code, because in the query I did not insert any limitation on the quantities of record to display.

  • Check, changed the code (my answer) to display the team name and player with the code of your table, made a semantic change, gives a check. Note that I also added the name of the "team" column in the query, adapt the name of your column to the "team name".

  • I checked and have no limitations on my code

  • Have you checked up on the change I made in my reply? Test in your development environment and then reply here.

  • I checked and gave nothing even

Show 6 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.