SHARE
TWEET

Untitled

a guest May 22nd, 2019 113 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Page Title</title>
  5. </head>
  6. <body>
  7.  
  8. <?php
  9.     ////////////////////////////////////////
  10.     // CONNECT DO DATABAZY lepsie si to dat do zvlast suboru a requirnut ho
  11.     ////////////////////////////////////////
  12.     $servername = "localhost";
  13.     $username = "username";
  14.     $password = "password";
  15.     $database = "password";
  16.  
  17.  
  18.     // Create connection
  19.     $conn = new mysqli($servername, $username, $password, $database);
  20.  
  21.     // Check connection
  22.     if ($conn->connect_error) {
  23.         die("Connection failed: " . $conn->connect_error);
  24.     }
  25.     ////////////////////////////////////////
  26.     // END OF CONNECT DO DATABAZY
  27.     ////////////////////////////////////////
  28. ?>
  29.  
  30. <table>
  31.   <tr>
  32.     <th>id</th>
  33.     <th>firstname</th>
  34.     <th>lastname</th>
  35.   </tr>
  36.  
  37. <?php
  38.     $sql = "SELECT id, firstname, lastname FROM MyGuests"; // SQL QUERY
  39.     $result = $conn->query($sql); // TUNA TI QUERNE TEN KOD A ZAPISE DO result vysledky
  40.    
  41.     while($row = $result->fetch_assoc()) { // to je ten while ciklus bude vypisovat dokim budu dalsie a dalsie riadky
  42.     ?>
  43.  
  44.     <tr>
  45.         <td><?php echo $row["id"];?></td>
  46.         <td><?php echo $row["firstname"];?></td>
  47.         <td><?php echo $row["lastname"];?></td>
  48.     </tr>
  49.  
  50.     <?php
  51.     ;};
  52.  
  53. ?>
  54.  
  55. </table>
  56.  
  57.  
  58. </body>
  59. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top