Advertisement
Guest User

Untitled

a guest
Oct 5th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>MovieClub Movie Index</title>
  6. <style>
  7. table, th, td {
  8. border: 1px solid black;
  9. }
  10. </style>
  11. </head>
  12. <body>
  13.  
  14. <h1>Movie Club Database Index</h1>
  15. <div>
  16.  
  17. </div>
  18. <div>
  19. <table>
  20. <tr><th>ID</th><th>Title</th><th>Director</th><th>Producer</th><th>Release_Date</th><th>Running_Time</th><th>Genre</th><th>Starring</th><th>Distributor</th></tr>
  21. <?php
  22. $servername = "localhost";
  23. $username = "root";
  24. $password = "";
  25. $database="movieclub";
  26.  
  27. // Create connection
  28. $conn = mysql_connect($servername, $username,$password,$database);
  29.  
  30. // Check connection
  31. if (!$conn) {
  32. die("Connection failed: " .mysql_connect_error());
  33. }
  34. //successful connection,
  35.  
  36. print_r(mysql_error($conn));
  37.  
  38.  
  39. $sql = "SELECT * FROM movies";
  40.  
  41. $result = mysql_query($sql,$conn);
  42.  
  43. if (is_object($result) && $result->num_rows > 0){
  44.  
  45. // output data of each row
  46. while($row = $result-> mysql_fetch_assoc()) {
  47. echo "<tr> <td> " . $row['ID']. "</td> <td> " . $row['Title']. "</td> <td> " . $row['Director']. "</td><td> " . $row['Producer']. "</td><td> " . $row['Release_Date']. "</td><td> " . $row['Running_Time']. "</td><td> " . $row['Genre']. "</td><td> " . $row['Starring']. "</td><td> " . $row['Distributor']. "</td> </tr>"; }
  48. }
  49. else {
  50. echo "0 results";
  51. }
  52. mysql_close($conn);
  53. ?>
  54. </table>
  55. </div><br>
  56. <div>
  57. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement