Advertisement
Guest User

Untitled

a guest
Sep 17th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <?php
  2.  
  3. $dbhost = "localhost";
  4.  
  5. $dbname = "musexchange";
  6.  
  7. $dbuser = "root";
  8.  
  9. $dbpass = "";
  10.  
  11.  
  12.  
  13.  
  14. mysql_connect ($dbhost, $dbuser, $dbpass) or die("Could not connect: ".mysql_error());
  15.  
  16. mysql_select_db ($dbname) or die(mysql_error());
  17.  
  18.  
  19.  
  20. $sql = "SELECT artist, name, year, rating FROM albums ORDER BY rating LIMIT 10";
  21.  
  22.  
  23.  
  24. $result = mysql_query($sql);
  25.  
  26. if (!$result) {
  27.  
  28. echo "Could not successfully run query ($sql) from DB: " . mysql_error();
  29.  
  30. exit;
  31.  
  32. }
  33.  
  34.  
  35.  
  36. while ($r = mysql_fetch_assoc($result)) {
  37. echo "<table>";
  38. echo "<tr>";
  39. echo "<th>".$r['artist']. "</th>";
  40. echo "<th>".$r['name']. "</th>";
  41. echo "<th>".$r['year']. "</th>";
  42. echo "<th>".$r['rating']. "</th>";
  43. echo "</tr>";
  44. echo "</table>";
  45. }
  46.  
  47.  
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement