Advertisement
Guest User

Untitled

a guest
Nov 27th, 2018
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.84 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="refresh" content="5">
  5. </head>
  6. <body>
  7. <style>
  8. #c4ytable {
  9.     font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  10.     border-collapse: collapse;
  11.     width: 100%;
  12. }
  13. #c4ytable td, #c4ytable th {
  14.     border: 1px solid #ddd;
  15.     padding: 8px;
  16. }
  17.  
  18. #c4ytable tr:nth-child(even){background-color: #f2f2f2;}
  19.  
  20. #c4ytable tr:hover {background-color: #ddd;}
  21.  
  22. #c4ytable th {
  23.     padding-top: 12px;
  24.     padding-bottom: 12px;
  25.     text-align: left;
  26.     background-color: #00A8A9;
  27.     color: white;
  28. }
  29. </style>
  30.  
  31. <?php
  32.    //Connect to database and create table
  33.    $servername = "localhost";
  34.    $username = "ubuntu";
  35.    $password = "tvtatk2018";
  36.    $dbname = "testDB";
  37.  
  38.    // Create connection
  39.    $conn = new mysqli($servername, $username, $password, $dbname);
  40.    // Check connection
  41.    if ($conn->connect_error) {
  42.         die("Database Connection failed: " . $conn->connect_error);
  43.     echo("testi");    
  44.   // echo "<a href='install.php'>If first time running click here to install database</a>";
  45.     }
  46. ?>
  47.  
  48. <div id="cards" class="cards">
  49.  
  50. <?php
  51.    $sql = "SELECT * FROM kosteussensori";
  52.    if ($result=mysqli_query($conn,$sql))
  53.    {
  54.      // Fetch one and one row
  55.      echo "<TABLE id='idkosteussensori'>";
  56.       echo "<TR><TH>idkosteussensori</TH><TH>maaperankosteus</TH><TH>idaikaleima</TH></TR>";
  57.       while ($row=mysqli_fetch_row($result))
  58.       {
  59.         echo "<TR>";
  60.         echo "<TD>".$row[0]."</TD>";
  61.         echo "<TD>".$row[1]."</TD>";
  62.         echo "<TD>".$row[2]."</TD>";
  63.         //echo "<TD>".$row[3]."</TD>";
  64.        // echo "<TD>".$row[4]."</TD>";
  65.        // echo "<TD>".$row[5]."</TD>";
  66.         echo "</TR>";
  67.       }
  68.       echo "</TABLE>";
  69.       // Free result set
  70.       mysqli_free_result($result);
  71.     }
  72.  
  73.     mysqli_close($conn);
  74. ?>
  75. </body>
  76. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement