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? Link to comment https://forums.phpfreaks.com/topic/17512-tricky-db-formatting-question/ 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 Link to comment https://forums.phpfreaks.com/topic/17512-tricky-db-formatting-question/#findComment-74487 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 Link to comment https://forums.phpfreaks.com/topic/17512-tricky-db-formatting-question/#findComment-74492 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 Link to comment https://forums.phpfreaks.com/topic/17512-tricky-db-formatting-question/#findComment-74493 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. Link to comment https://forums.phpfreaks.com/topic/17512-tricky-db-formatting-question/#findComment-74501 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. Link to comment https://forums.phpfreaks.com/topic/17512-tricky-db-formatting-question/#findComment-74505 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.