Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dbhost = "localhost";
- $dbname = "musexchange";
- $dbuser = "root";
- $dbpass = "";
- mysql_connect ($dbhost, $dbuser, $dbpass) or die("Could not connect: ".mysql_error());
- mysql_select_db ($dbname) or die(mysql_error());
- $sql = "SELECT artist, name, year, rating FROM albums ORDER BY rating LIMIT 10";
- $result = mysql_query($sql);
- if (!$result) {
- echo "Could not successfully run query ($sql) from DB: " . mysql_error();
- exit;
- }
- while ($r = mysql_fetch_assoc($result)) {
- echo "<table>";
- echo "<tr>";
- echo "<th>".$r['artist']. "</th>";
- echo "<th>".$r['name']. "</th>";
- echo "<th>".$r['year']. "</th>";
- echo "<th>".$r['rating']. "</th>";
- echo "</tr>";
- echo "</table>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement