'HTML elements not displayed in the right order using PHP echo

I am trying to build a tool that allows sports teams management using HTML/CSS and PHP, but I am encountering some difficulties displaying the results of some queries. As you can see in the screen shot the variable $tablea_match which contains the table with the names of all players is called first but is displayed last. 'Envoyer' should be displayed under the table, and the name and '+' after that form.

enter image description here

You can see both the HTML + PHP part that is supposed to display it and here is the code which I used to construct the table:

    $tableau_matchs = "
    <table style=\"\">
    <tr>
        <th>Joueur</th>
        <th>Titulaire</th>
        <th>Note Match</th>
        <th>Retirer</th>
    </tr>";
  
    
    while($data = $res->fetch()){
        $tableau_matchs .= "<tr>
        <th> ".$data['joueur']."</th>
        <td><input type = \"checkbox\" name = \"titulaire_".$data['numeroLicence']."\" ".checkTitulaire($data['titulaire'])."></td>
        <td> 
            <select name='note_match_".$data['numeroLicence']."'> 
                ".dropdown($data['note'])."
            </select>
        </td>
        <td><input type = \"checkbox\" name = \"supprimer_".$data['numeroLicence']."\"></td>
        </tr>";
    
        }

Is there something I am not doing right ?



Solution 1:[1]

make sure you are closing the html table after the loop

$tableau_matchs .= "</table>;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Omar Tammam