how to do it
i m new at databases and stuff. haven't read them after university :D so i m making page which have songs. i got the songs list.. but i don't know how to get information about the song like genre,ratings and stuff from other table i created. coz its like when the person clicks the link. he is send to another page and there the related song information is showed. how should i be doing it. joins or what?
I don't know. What does your database look like? What data from which tables do you want to show?
i have one table with id,artist,song,length,run time and i was thinking to make another table for storing pictures of that song. or perhaps do it in the same table?
More than 1 picture per song? A different table.
No need for the album name? If you do, then you'd make a new albums table, move the artist from the songs table to the albums table, and add an album_id to the songs table.
i'll see that though i am having hard time imagining. when a person clicks on a song and he is taken to the song page. how should i do the query.? get album_id on same page 1 and all the info about the song. put them in variable and post to it to the next page? (ofcourse the query on page of getting info about song won't be displayed on page 1 but on page 2)
The albums table was just an idea. If you don't need it, forget about it. Let's not complicate things too much ;)
What you need to send to page 2 is the key that identifies the song that the user has clicked. I guess that would be the id from the songs table.
So you'd have a link on page 1 like
And in page2.php you'd get the id from the query string ($_GET['id']) and use that in your query after sanitizing its value to get all the song info.
<a href="page2.php?id=1>a beautiful song</a>
If you need to get the images from the songimages table as well, then you'll have to join the songs table and the images table.
actually i do need it coz when album is clicked it shows album page
Originally Posted by guido2004
Ok. So you'd send the song id to the songs page, and join the songs, albums and songimages tables to get all the info for that song you need.
Similarly, you'd send the album id to the albums table (when an album is clicked), and join the albums and songs tables to get all the info for that album you need.
Attention though: since an album can contain more than 1 song, joining the albums table to the songs table based on an album id will give you multiple rows with the album info duplicated. You'll have to write your code to manage that situation.
The same goes for the join between the songs table and the songimages table.
hmm sound hard. but will get there i hope.