Forum Moderators: coopster
Now if on the next row the Artist Name changes, I would like to put in another Image so:
Image1
Artist Name1
Artist Name1
Artist Name1
Image2
Artist Name2
Artist Name2
Artist Name2
However, I don't know how to compare the row with Artist 2 to the previous row using mysql_fetch_array.
My code is below:
$loopct = 0;
while ($rowAlbums = mysql_fetch_array($detailsAlbums, MYSQL_BOTH))
{
if ($loopct == 0)
{
echo "<tr><td><img src='".$rowAlbums['PicturePath']."'></td><td colspan = '6'>".$rowAlbums['Artist']." - ".$rowAlbums['Title'].";
}
//etc. listing the rest of the details
$loopct = 0;
while ($rowAlbums = mysql_fetch_array($detailsAlbums, MYSQL_BOTH))
{
if ($loopct == 0)
{
echo "<tr><td><img src='".$rowAlbums['PicturePath']."'></td><td colspan = '6'>".$rowAlbums['Artist']." - ".$rowAlbums['Title'].";
$last_artist = $rowAlbums['Artist'];
$loopct++;
}
elseif($rowAlbums['Artist']!= $last_artist)
{
//echo img etc.
$last_artist = $rowAlbums['Artist'];
}
else
{
//No img, just artist name
$last_artist = $rowAlbums['Artist'];
}
}
Note that this will only work if you're looking at just the previous artist. If you want to check whether the artist has been displayed at all, add the names to an array and do an array_search instead of elseif($rowAlbums['Artist']!= $last_artist).