Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.61 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <link rel="stylesheet" type="text/css" href="css/leer.css">
  5.     <meta charset="utf-8">
  6.     <title>Leer</title>
  7. </head>
  8. <body>
  9.     <?php
  10.         $servername = "localhost";
  11.         $username = "root";
  12.         $password = "";
  13.         $dbname = "servidormysql";
  14.  
  15.         // Create connection
  16.         $conn = new mysqli($servername, $username, $password, $dbname);
  17.         // Check connection
  18.         if ($conn->connect_error) {
  19.             die("Connection failed: " . $conn->connect_error);
  20.         }
  21.  
  22.         $sql = "SELECT id, name, pass, x, y, z, a, interior, vw, skin, edad  FROM users";
  23.         $result = $conn->query($sql);
  24.  
  25.         if ($result->num_rows > 0) {
  26.             echo "<table><tr>
  27.  
  28.             <th>ID</th>
  29.  
  30.             <th>Nombre</th>
  31.  
  32.             <th>Contraseña</th>
  33.  
  34.             <th>Posición X</th>
  35.  
  36.             <th>Posición Y</th>
  37.  
  38.             <th>Posición Z</th>
  39.  
  40.             <th>Posición A</th>
  41.  
  42.             <th>Interior</th>
  43.  
  44.             <th>Virtual World</th>
  45.  
  46.             <th>Skin</th>
  47.  
  48.             <th>Edad</th>
  49.  
  50.             </tr>";
  51.             // Salida de los datos
  52.             while($row = $result->fetch_assoc()) {
  53.                 echo "<tr>
  54.                 <td>".$row["id"]."</td>
  55.                 <td>".$row["name"]."</td>
  56.                 <td>".$row["pass"]."</td>
  57.                 <td>".$row["x"]."</td>
  58.                 <td>".$row["y"]."</td>
  59.                 <td>".$row["z"]."</td>
  60.                 <td>".$row["a"]."</td>
  61.                 <td>".$row["interior"]."</td>
  62.                 <td>".$row["vw"]."</td>
  63.                 <td>".$row["skin"]."</td>
  64.                 <td>".$row["edad"]."</td>
  65.                 </tr>";
  66.             }
  67.             echo "</table>";
  68.         } else {
  69.             echo "No hay ningún usuario registrado en la base de datos!";
  70.         }
  71.         $conn->close();
  72.     ?>
  73. </body>
  74. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement