Synergic Posted August 14, 2006 Share Posted August 14, 2006 Ok i've got a CD catalog in a database. I have a cd table in the cd table i have a column for the artist, song and publisher. What i want to do is list each artist under their publisher so something likeSony/BMG Artist 1 Artist 2Universal Artist 1 Artist 2I'm just having trouble approaching the problem of printing it out. How do i populate each artist under their respective publisher? Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 14, 2006 Share Posted August 14, 2006 Don't!Just have a table of artist and a field for their publisher Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 14, 2006 Share Posted August 14, 2006 [quote author=ToonMariner link=topic=104209.msg415452#msg415452 date=1155565618]Don't!Just have a table of artist and a field for their publisher[/quote]u can do 1 field, and run a MySQL query with php to get the result u want Quote Link to comment Share on other sites More sharing options...
shocker-z Posted August 14, 2006 Share Posted August 14, 2006 [code]$publisher='';$sql="SELECT artist, publisher FROM table ORDER by publisher DESC";$resulte=mysql_query($sql) or die(mysql_error());while ($row=mysql_fetch_array($result)) { if ($row['publisher'] !== $publisher) { echo ("<H1>$row[publisher]</H1><Br>"); $publisher=$row['publisher']; } echo($row['artist'].'<Br>');}?>[/code]That should do the trick :)RegardsLiam Quote Link to comment Share on other sites More sharing options...
Synergic Posted August 14, 2006 Author Share Posted August 14, 2006 [quote author=ToonMariner link=topic=104209.msg415452#msg415452 date=1155565618]Don't!Just have a table of artist and a field for their publisher[/quote]for simplicity i have kept things in one table. i will fix the structure once i've figured this problem. Quote Link to comment Share on other sites More sharing options...
Synergic Posted August 14, 2006 Author Share Posted August 14, 2006 nerver mind, my bad :) thanks for the help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.