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
https://forums.phpfreaks.com/topic/122587-php-database/#findComment-632960
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
https://forums.phpfreaks.com/topic/122587-php-database/#findComment-633014
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
https://forums.phpfreaks.com/topic/122587-php-database/#findComment-633033
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
https://forums.phpfreaks.com/topic/122587-php-database/#findComment-633044
Share on other sites

Archived

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

×
×
  • 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.