Northern Flame Posted June 25, 2007 Share Posted June 25, 2007 Hello, I created a page on my website that displays the artists of songs uploaded on my website, and I want to make it so that when you click on the artist, it will display all of his/her songs without me having to create a page for every artist and manually having to input their song titles. I've already made it so that it displays the artists, but I have no idea how to make it display all the songs that I have on my website that are by the artist that the user selects, I've tried so many things and none seem to work heres the code that displays the artists, maybe this can help anyone who tries to help me, while($row = mysql_fetch_array($sql)){ $artist = $row['name_artist']; echo "<a href=\"".$_SERVER['PHP_SELF']."?artist=$artist\">".$row['name_artist']."</a><br /><br />"; } Heres My Tables mp3_artists: - id_artist - name_artist mp3_musics - id_music - title_music - playlist_music - date_music - active_music I can create a table joining the two, well, the important data, but how would I get the song titles to be displayed on the artist page? How can I tell the script to display the music of the artist that is clicked on? Or do I create a seperate page, lets say "artist_music.php", but still, how will I tell the script to only display the music from the artist that was clicked on? The only solution I came up with was to make a page for each artist and manually put in the music names, but if theirs a way to do one of the first two options I WOULD MUCH RATHER PREFER TO DO THAT! ANY RESPONSED WOULD BE GREATLY APPRECIATED!! Quote Link to comment Share on other sites More sharing options...
AndyB Posted June 25, 2007 Share Posted June 25, 2007 In your mp3_musics table you need a field for the artist id (a reference back to the mp3_artists table). Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted June 25, 2007 Author Share Posted June 25, 2007 ok, now lets say I create a new table, lets call it mp3_join and lets say it includes this title_music name_artist and maybe some other stuff, then, how will I be able to display the songs of the artist that the user clicked on? Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted June 25, 2007 Share Posted June 25, 2007 U have to use id like artist_id as a unique id as AndyB mention earlier. That id will know that this song is related to this artist. U have to see first normalization on db. Quote Link to comment Share on other sites More sharing options...
AndyB Posted June 25, 2007 Share Posted June 25, 2007 Before you go creating more tables, stop and think about how your data is going to be used - next week, next month, next year, not just in the next five minutes. What purpose would your mp3_join have and what's the "other stuff"? Quote Link to comment Share on other sites More sharing options...
suma237 Posted June 25, 2007 Share Posted June 25, 2007 Try this Create 2 tables mp3_artists: - id_artist - name_artist mp3_musics -id_artist - id_music - title_music - playlist_music - date_music - active_music now the table mp3_musics will have foreginkey relation with first table and write one join query Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted June 25, 2007 Author Share Posted June 25, 2007 oh alright, sorry its just that im new to using MySQL and i didnt know about the joining tables so I had no idea what you guys were talking about until i looked it up on google LOL, but now I think I know how to get this done, THANKS FOR ALL THE REPLIES!! 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.