Advertisement
Guest User

Untitled

a guest
Apr 5th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. <?php
  2. require "Conn.php";
  3. ?>
  4.  
  5. <?php
  6.  
  7. $db = mysqli_connect('', '', '', '') or die('Error connecting to MySQL server.');
  8. ?>
  9.  
  10. <?php
  11. $servername = "";
  12. $username = "";
  13. $password = "";
  14. $database = "";
  15. if (mysqli_connect_errno()){
  16. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  17. }
  18.  
  19. $conn = new mysqli($servername, $username, $password, $database);
  20.  
  21. if ($conn->connect_error) {
  22. die("Connection failed: " . $conn->connect_error);
  23. }
  24.  
  25. if(mysqli_connect_errno()){
  26. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  27. }
  28.  
  29. $sql = "SELECT * FROM view";
  30. $result = mysqli_query($conn, $sql);
  31.  
  32. if (mysqli_num_rows($result) > 0) {
  33. // output data of each row
  34. while($row = mysqli_fetch_assoc($result)) {
  35. echo "<table border = 5>";
  36. echo "<tr>";
  37. echo "
  38. <th>RID</th>
  39. <th>BID</th>
  40. <th>Viewing</th>";
  41. echo "</tr>";
  42.  
  43.  
  44. while($row = mysqli_fetch_array($result)){
  45. echo "<tr>";
  46. echo "<td>" . $row['RID'] . "</td>";
  47. echo "<td>" . $row['BID'] . "</td>";
  48. echo "<td>" . $row['Viewing'] . "</td>";
  49. echo "</tr>";
  50. }
  51. echo "</table>";
  52. }
  53. } else {
  54. echo "0 results";
  55. }
  56.  
  57. echo "$result";
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement