Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Page Title</title>
- </head>
- <body>
- <?php
- ////////////////////////////////////////
- // CONNECT DO DATABAZY lepsie si to dat do zvlast suboru a requirnut ho
- ////////////////////////////////////////
- $servername = "localhost";
- $username = "username";
- $password = "password";
- $database = "password";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $database);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- ////////////////////////////////////////
- // END OF CONNECT DO DATABAZY
- ////////////////////////////////////////
- ?>
- <table>
- <tr>
- <th>id</th>
- <th>firstname</th>
- <th>lastname</th>
- </tr>
- <?php
- $sql = "SELECT id, firstname, lastname FROM MyGuests"; // SQL QUERY
- $result = $conn->query($sql); // TUNA TI QUERNE TEN KOD A ZAPISE DO result vysledky
- while($row = $result->fetch_assoc()) { // to je ten while ciklus bude vypisovat dokim budu dalsie a dalsie riadky
- ?>
- <tr>
- <td><?php echo $row["id"];?></td>
- <td><?php echo $row["firstname"];?></td>
- <td><?php echo $row["lastname"];?></td>
- </tr>
- <?php
- ;};
- ?>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement