$flag = false;
$flag2 = false;
$data = mysql_query("SELECT * FROM album ORDER BY type, year ASC") or die(mysql_error());
while ($info = mysql_fetch_array( $data )){
$type = $info['type'];
if ($type == "A" && $flag == false) {
echo "<h3>Albums</h3>";
$flag=true;
}
if ($type == "A") {
echo "<A HREF=\"album.php?album=$info[albumname]\">";
echo "$info[albumname]";
echo "</A>";
echo " | ";
}
if ($type == "S" && $flag2 == false) {
echo "<h3>Singles</h3>";
$flag2 = true;
}
if ($type == "S") {
echo "<A HREF=\"album.php?album=$info[albumname]\">";
echo "$info[albumname]";
echo "</A>";
echo " | ";
}
}
ok, what this code does is print a list of albums in the form of
Albums
album1 | album2 | album3 |
Singles
single1| single2|
and what I would like to do is get rid of that last | after the last album, and also, is there a more efficient way of doing this code? I am a complete novice, but I am learning as I go!
If it helps, the $type variable is a char(1) and obviously means album or single.
Thanks for any help!