steadicamop
07-13-2008, 08:28 PM
I'm trying to knock up a relatively simple script for accessing a database to pull out the Artist and Title of an album ... but there is a small issue of the fact that these are stored in tables which have 1 entry for each track (so it could effectively be 15 entries for the same Artist/Album). I've been trying to figure out how to pull both of these, but only once for unique results (I did use DISTINCT but it only apparently works on one column).
Here is the code I have at present:
$result = mysql_query("SELECT album, artist FROM samdb.songlist ORDER BY date_added DESC LIMIT 10")
or die(mysql_error());
echo "<table>";
echo "<tr><td colspan='2' align='center'>Ten Latest Albums</td></tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['artist'];
echo "</td><td>";
echo " - ".$row['album'];
echo "</td></tr>";
}
echo "</table>";
I found this example from another site which I've used ... it's definately not tidy, but I think is close enough for what I need to do!
What I basically need it to do is display one album title, even if there are 15 entries in the table, then if it finds any blank entries, discount them.
Hope this made some sense!
Jase
Here is the code I have at present:
$result = mysql_query("SELECT album, artist FROM samdb.songlist ORDER BY date_added DESC LIMIT 10")
or die(mysql_error());
echo "<table>";
echo "<tr><td colspan='2' align='center'>Ten Latest Albums</td></tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['artist'];
echo "</td><td>";
echo " - ".$row['album'];
echo "</td></tr>";
}
echo "</table>";
I found this example from another site which I've used ... it's definately not tidy, but I think is close enough for what I need to do!
What I basically need it to do is display one album title, even if there are 15 entries in the table, then if it finds any blank entries, discount them.
Hope this made some sense!
Jase