Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html lang="es">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Mostrar datos</title>
- </head>
- <?php
- $dbhost="hostname";
- $dbuser="user";
- $dbpass="pass";
- $db="dbname";
- $conn = mysql_connect ($dbhost, $dbuser, $dbpass) or die ("Error al conectar don bd: $dbhost, $dbuser, $dbpass" . mysql_error());
- mysql_select_db ($db);
- $sql="SELECT campo1, campo2, campo3
- FROM tabla
- WHERE condicion
- ORDER BY campo1;";
- $consulta=mysql_query($sql);
- ?>
- <body>
- <table>
- <thead>
- <tr>
- <th>campo1</th>
- <th>campo2</th>
- <th>campo3</th>
- </tr>
- </thead>
- <tbody>
- <?php
- while ($fila = mysql_fetch_assoc($consulta)) {
- echo "<tr><td>".$fila['campo1']."</td>
- <td>".$fila['campo2']."</td>
- <td>".$fila['campo3']."</td>
- </tr>";
- }
- ?>
- </tbody>
- <?
- mysql_free_result($consulta);
- mysql_close($conn);
- ?>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement