Advertisement
Guest User

Untitled

a guest
Oct 20th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "mekaanikko";
  6. $dbname = "TESTI";
  7.  
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11. die("Connection failed: " . $conn->connect_error);
  12. }
  13.  
  14. $sql = "SELECT Name, Address, Phone, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Comment FROM Form";
  15. $result = $conn->query($sql);
  16.  
  17. if ($result->num_rows > 0) {
  18. echo "<table style='width=100%'>"
  19. echo "<tr><th>Name</th><th>Address</th><th>Phone</th><th>Q1</th><th>Q2</th><th>Q3</th><th>Q4</th><th>Q5</th><th>Q6</th><th>Q7</th><th>Comment</th></tr>"
  20. while($row = $result->fetch_assoc()) {
  21. echo "<tr>";
  22. echo "<td>$row["Name"]</td>";
  23. echo "<td>$row["Address"]</td>";
  24. echo "<td>$row["Phone"]</td>";
  25. echo "<td>$row["Q1"]</td>";
  26. echo "<td>$row["Q2"]</td>";
  27. echo "<td>$row["Q3"]</td>";
  28. echo "<td>$row["Q4"]</td>";
  29. echo "<td>$row["Q5"]</td>";
  30. echo "<td>$row["Q6"]</td>";
  31. echo "<td>$row["Q7"]</td>";
  32. echo "<td>$row["Comment"]</td>";
  33. echo "</tr>";
  34. }
  35. echo "</table>"
  36. } else {
  37. echo "0 results";
  38. }
  39. $conn->close();
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement