[RESOLU] Problème d'affichage de mon code PHP

Avatar du membre
Petit nouveau ! | 4 Messages

04 déc. 2022, 21:01

Bonjour,
Mon code PHP est sensé m'afficher un tableau avec des données provenant d'une base de donnée MySQL.
La première ligne est bien affichée correctement, avec (1) les bonnes valeurs et (2) dans un tableau.
Mais la deuxième ligne est... buggée.
Voici ce que sa me donne :

Code : Tout sélectionner

<body> <center> <h1>OSWorldTour Database</h1> <script>console.log("Connection succesfull.");</script> <table><tbody> <tr> <th>OS Name</th> <th>Confirmed</th> <th>OS Version</th> <th>OS Edition</th> <th>OS Developper</th> <th>OS Language</th> <th>OS Date</th> <th>File parts</th> <th>Leaked by</th> <th>SHA-256 Sum</th> <th>Download Link</th> </tr><tr> <td>Windows 1.0</td> <td>1</td> <td>Developpers Release 5</td> <td>Unknown</td> <td>Microsoft</td> <td>English</td> <td>1984</td> <td>3</td> <td>Unknown</td> <td>Unknown</td> <td><a href="[un lien]">Download</a></td></tr> </tbody> </table> test0idkUnknownidkidk20011idkidk<a href="[un lien]">Download</a> </center> </body>
En gros:
la première ligne est dans le tableau
la deuxième ne l'est pas, et elle est même à l'extérieur de la balise <table></table>
Voici le code qui affiche le tableau :

Code : Tout sélectionner

// Get results from database $sqlcommand = "SELECT * FROM osdb"; $result = $conn->query($sqlcommand); // Show the results if ($result->num_rows > 0) { echo "<table>"; echo "<tr><th>OS Name</th><th>Confirmed</th><th>OS Version</th><th>OS Edition</th><th>OS Developper</th><th>OS Language</th><th>OS Date</th><th>File parts</th><th>Leaked by</th><th>SHA-256 Sum</th><th>Download Link</th></tr>"; // Output data of each row while($row = $result->fetch_assoc()) { echo "<tr><td>" . $row['osname'] . "</td><td>" . $row['isconfirmed'] . "</td><td>" . $row['osversion'] . "</td><td>" . $row['osedition'] . "</td><td>" . $row['osdevelopper'] . "</td><td>" . $row['oslanguage'] . "</td><td>" . $row['osdate'] . "</td><td>" . $row['fileparts'] . "</td><td>" . $row['leakedby'] . "</td><td>" . $row['sha256sum'] . '</td><td><a href="' . urldecode($row['downloadlink']) . '">Download</a></td></tr>'; echo "</table>"; } } else { echo "No OSes has being added... For now ! :)"; }
Quelqu'un peut il m'aider SVP ? Merci d'avance !

Mammouth du PHP | 2703 Messages

04 déc. 2022, 21:31

avec
echo "</table>";
dans le while, cela va marcher beaucoup moins bien.

à noter que le html généré montré comprend </tbody> que l'on ne retrouve pas dans le code php.

Avatar du membre
Petit nouveau ! | 4 Messages

04 déc. 2022, 22:03

Merci beaucoup, je n'avais pas vu !