/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /* how to create connexion (4th parameter = default database) */ $mysqli = new mysqli($host, $usr, $pass, $db); /* how to verify connexion */ } /* how to set the default charset to use */ if (!$mysqli->set_charset("utf8")) { } /* how to use real_escape_string on string */ $nom = $mysqli->real_escape_string($nom); $mail = $mysqli->real_escape_string($mail); $tel = $mysqli->real_escape_string($tel); /*how to get data in a table with a while */ $query = "SELECT nom, mail, tel FROM ufr_jury ORDER by nom;"; $ressource = $mysqli->query($query); while($result = $ressource->fetch_assoc()){ echo "<tr>"; echo "<td>".$result['nom']."</td>"; echo "<td>".$result['mail']."</td>"; echo "<td>".$result['tel']."</td>"; echo "</tr>"; } /* how to free result ressource */ $ressource->close(); /* how to close connection */ $mysqli->close(); ?>