Forum Moderators: coopster
That should work, assuming I've made no simple mistake/typo.<?php
$sql = 'SELECT artist_name, artist_role FROM music_table ORDER BY artist ASC';
$result = mysql_query($sql);
$rows = mysql_num_rows($result);
for($i = 0; $i < $rows; $i++) {
$roles[$i] = array(mysql_result($result, $i, "artist_name"), mysql_result($result, $i, "artist_role"));
}
$output = '<table cellspacing="2">
<tr>
<td><span style="font-weight: bold">Artist</span></td>
<td><span style="font-weight: bold">Role</span></td>
</tr>';
$count = count($roles);
for($i = 0; $i < $count; $i++) {
if($roles[$i][0] === $roles[($i - 1)][0]) {
$art = '-';
} else {
$art = $roles[$i][0];
}
$output .= "\n" . '<tr>' . "\n" . '<td>' . $art . '</td>' . "\n" . '<td>' . $roles[$i][1] . '</td>' . "\n" . '</tr>';
}
$output .= "\n" . '</table>';
echo $output;
?>
$artist_list=$name_value=$new_name=NULL;
$sql = "select artist_name, instrument from artists order by artist";
$result = mysql_query($sql);
while ($row=mysql_fetch_array($result)) {
$instrument = $row['instrument'];
$name_value = ($new_name==$row['artist_name'])?'--------':$row['artist_name'] . ' - ';
if ($row['artist_name'] != $new_name) { $new_name = $row['artist_name']; }
$artist_list .= "<li>$name_value $instrument</li>\n";
}
//
if ($artist_list) {
echo "
<h5>Artists:</h5>
<ul>$artist_list</ul>
";
}
else { echo "<p><em>Artist list for this album is not available at this time.</em></p>"; }