I'd recommend changing a bunch of things. However, other than your issue with the while loop and missplaced curly brackets, I see no reason for no output. And even with that error, you should get all output from the last row of data (if any rows are retrieved) along with the artist from every row.
Is error reporting / logging turned on?
# I'd recommend $db = mysql_connect(...) or $conn = mysql_connect(...)
# so that you actually have a reference to your database connection resource.
# As long as you only every use one resource, that resource will be used.
# But if you ever need another connection, you will need to specify which connection to use
$conn = mysql_connect('localhost', 'xxxxx', 'xxxx');
mysql_select_db('xxxx') or die(mysql_error());
# I'd also changing names from $db to $result, since what you get from mysql_query is a result set
# resource. Thus, calling it $result provides better information when reading the code.
$result = mysql_query("SELECT categorylist.*, songlist.id, songlist.info, songlist.title, songlist.picture, songlist.artist, songlist.date_added FROM categorylist, songlist WHERE categoryid = 1 AND categorylist.songid=songlist.id ORDER BY date_added DESC LIMIT 20");
# Indent your code properly
if (!$result)
{
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
# Never display this kind of error messages to the end user.
error_log($message);
echo 'An error occurred. Please try again. If the problem persists, <a href="mailto:support@example.com">contact support</a>.';
exit;
}
# This, is the exact same thing as
while($row = mysql_result($result))
echo $row['artist'];
# This
while($row = mysql_result($result))
{
echo $row['artist'];
}
echo $row['title'];
echo $row['info'];
echo $row['date_added'];
# And since these brackets aren't preceeded by any kind of control type structure, this block will always
# be executed (once)
{
echo "<tr bgcolor='#ffffff'>";
echo " <td>";
echo " <img align=left src='$picture_na" . rawurlencode($row["picture"]) ."', width='60' height='60'>";
echo " <p align='left'>";
echo " <font face=Verdana color=teal size=1><b>ARTIST: <i><a href='javascript:songinfo(". $row["id"] . ")'>" . $row["artist"] . "</a></i></font><br>";
echo " <font face=Verdana color=teal size=1><b>TITLE: <i>'" . $row["title"] ."' </i></font><br>";
echo " <font face=Verdana color=teal size=1><b>INFO: </b><a href=' " . $row["info"] ."'>" . $row["info"] . "</a><font><br>";
echo " <font face=Verdana color=teal size=1><b>ADDED: </b></font><font face=Verdana color=red size=1><b>".substr($row["date_added"],5,2)."/".substr($row["date_added"],8,2)." </b></font>";
echo " </p>";
echo " </td>";
echo "</tr>";
}
echo "</table>";
# You should wrap the entire while loop in { }, and also most likely get rid of those 4 first echoe statements.
# So, instead do this
while($row = mysql_result($result))
{
echo "<tr bgcolor='#ffffff'>";
echo " <td>";
echo " <img align=left src='$picture_na" . rawurlencode($row["picture"]) ."', width='60' height='60'>";
echo " <p align='left'>";
echo " <font face=Verdana color=teal size=1><b>ARTIST: <i><a href='javascript:songinfo(". $row["id"] . ")'>" . $row["artist"] . "</a></i></font><br>";
echo " <font face=Verdana color=teal size=1><b>TITLE: <i>'" . $row["title"] ."' </i></font><br>";
echo " <font face=Verdana color=teal size=1><b>INFO: </b><a href=' " . $row["info"] ."'>" . $row["info"] . "</a><font><br>";
echo " <font face=Verdana color=teal size=1><b>ADDED: </b></font><font face=Verdana color=red size=1><b>".substr($row["date_added"],5,2)."/".substr($row["date_added"],8,2)." </b></font>";
echo " </p>";
echo " </td>";
echo "</tr>";
}
# Moreover, you should make sure you have correct html markup. You were missing an opening table tag.
# You are also using the deprecated font element and align attribute. Use css stylesheets or inline styles.
# Here I'm putting inline style information in the p element (update: there should be no p element; since
# you are dealing with tabular data and are allready using a table, use the table properly. I'm now
# putting this style information in the td element instead
# since the other rows seem to all use the same
# styling. The b element is also deprecated since it has no semanti meaning. Instead, use em (emphasis)
# and styling to get the same visual effect as the b element did
# style elements should rather go in the head section of the document, or even in a separate file
echo '<style type="text/css">
/* some browsers displays this element as italic and non-bold by default
so you need to change this if you want normal bold text. */
em
{
font-weight: bold;
text-transform: none;
}
td
{
font-family: Verdana, Arial, Helvetica, sans-serif;
text-align: left;
color: teal;
font-size: 0.8em;
}
/* also, you should rarely ever use br element. HTML 5 says:
* br elements must be used only for line breaks that are actually part of the content,
* as in poems or addresses.
* Otherwise you use styling to get the appropriate amount of whitespace (padding or margin)
*/
td, th
{
padding: 0.25em 0.33em;
}
th
{
font-weight: bold;
font-size: 1.1em;
}
</style>
';
# And that might instead go in a separate file and instead (also in the head element of the page)
# echo '<link rel="stylesheet" type="text/css" href="path/to/file.css">';
# The font element's size attribute ranged from 1 to 7, whith 3 being standard size.
# Nowdays, either use em or % to change size from the size of the parent element (currently used size).
# In your case, you are saying you want a smaller size, so let's go with 0.8 em (same as 80%)
# You should also provide fallback fonts if the one you want isn't present on the users system. In your case
# that means at the very least font-family: Verdana, sans-serif
# The b element should pretty much never be used. Headers should use h1-h6, important stuff should use strong, stress
# emphasis should use em, marked/highlighted text should use m. And in your case, you are actually putting
# several different items of data in the same table cell, while preceeding each with a label defining
# what kind of data it is. But in that case you should NOT be using a table to begin with, or if you are
# really dealing with tabular data (you are) those labels should go in the table head (column titles)
echo '<table>
<thead>
<tr>
<th>Picture</th><th>Artist</th><th>Title</th><th>Info</th><th>Added</th>
</tr>
</thead>
<tbody>
';
while($row = mysql_result($result))
{
# bgcolor is deprecated
echo "<tr style='background-color: #ffffff'>";
# rawurlencode is used if you want to protect characters from being interpreted as having special meaning
# IN a URL (i.e. when it's used as a URL). You should use htmlentities instead. I'm assuming you use utf-8
# character encoding
echo " <td><img align=left src='$picture_na" . htmlentities($row["picture"], ENT_QUOTES, 'utf-8') ."', width='60' height='60'></td>";
# i element is used to represent text in an alternate voice or mood or otherwise offset from the normal prose
# but since you only have one text item per cell, it seems superflous to do so. Also, you mark up ALL your cells
# to be "in an alternate mood". But when everything is alternate... it's no longer alternate. If you want
# your cell data to be italicized (which the i element doesn't have to be), then specify in your css
# td { text-transform: italic; }
echo " <td><a href='javascript:songinfo(". $row["id"] . ")'>" . $row["artist"] . "</a></td>";
echo " <td>" . $row["title"] ."</td>";
echo " <td><a href=' " . $row["info"] ."'>" . $row["info"] . "</a></td>";
echo " <td>".substr($row["date_added"],5,2)."/".substr($row["date_added"],8,2)."/td>";
echo "</tr>";
}
echo "
<tbody>
</table>";