Jump to content

php database


dillonit

Recommended Posts

Yes there is.

You can have variable length playlists by adding one more table

 

table playlists_songs
playlist_id,song_id
     1           1
     1           2
     1           3
     2           1
     2           4
     2           5

etc...

 

 

 

Link to comment
Share on other sites

You'd need one query to display playlist data

SELECT playlist_name FROM playlistTable WHERE playlist_id = 1

 

And another to get items on this playlist

 

SELECT song_name, song_link FROM songTable AS s, playlists_songs AS ps WHERE ps.song_ID = s.song_ID AND ps.playlistID = 1

Link to comment
Share on other sites

Ok sorry for all the questions.

 

If there are going to be multiple numbers that are the same, how can i put a primary key on them.

 

I have one playlist already listed in the playlist_song_table. And the songs and playlist in there respected tables as well.

1,1

1,2

1,3

1,4

1,5.....

1,17

 

 

I tried to add the primary key after the data was already in there. I am using phpmyadmin to do this. Do i need to set the primary keys first then add the data?

Link to comment
Share on other sites

1. Delete primary key for that table if you have one.

2. Display the table in 'structure' view.

3. Select both rows with checkboxes.

4. Under a table with rows, should be an icon for primary key, click it.

 

You should now have primary key that's based on two columns.

 

Mind, that it means, you one song can't occur more than once within one playlist

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.