Jump to content

Archived

This topic is now archived and is closed to further replies.

Synergic

tricky db formatting question

Recommended Posts

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 like


Sony/BMG

  Artist 1
  Artist 2

Universal

  Artist 1
  Artist 2

I'm just having trouble approaching the problem of printing it out. How do i populate each artist under their respective publisher?

Share this post


Link to post
Share on other sites
[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

Share this post


Link to post
Share on other sites
[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 :)

Regards
Liam

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.