Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>MySQLi example</title>
- <meta charset="utf8">
- </head>
- <body>
- <?php
- // Usaremos una base de datos (foobar) con una tabla (users) que contiene username y email.
- $user = "root"
- $password = "mipasswordtopeguapens"
- $ddbb = "foobar"
- $con = new mysqli("localhost", $user, $password, $ddbb);
- // select a lo bestia porque yolo
- $sql_query= "select * from users";
- // amoh ahí palante esa consulta
- $result = $con->query($sql_query);
- // y ahora la sacamos por pantalla
- echo "<h1>Lista de usuarios</h1>";
- echo "<table>";
- // la consulta devuelve un array asociativo, así que toca patearselo
- while($row = $result->fetch_assoc()) {
- echo "<tr><td>" . $row['username'] . "</td>" . "<td>" . $row['email'] . "</td></tr>";
- }
- echo "</table>";
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment