Now I found a code that I modified and it is doing what I want (almost). The code is generating the music genre from a table of songs (with a lot of info) called table_genre with the fields genre_id and genre_name.

These are included in a form as checkboxes. The user can check one or more boxes of the genres that suit the song.

Then I want to input this into my table called songs_genre, but right now I only have it on my screen separated with comma.

PHP Code:

$song_genre count($_POST['song_genre']) ? $_POST['song_genre'] : array();

//echo out the choices separated by a comma
echo count($song_genre) ? implode(', ',$song_genre) : 'Nothing!'
I picked code from something I found when I googled it. But I want my output to be inserted into my db called songs_genre. Here I like to insert the song_genre from the form and also one called $song_id so the genres selected are connected to the song that is used on the actual form.

Can anyone tell me how to change the code above, so it is inserted as separated lines together with the song_id into my table called song_genre

If the song is $song_id=32. The genre is rock (song_genre 5), instrumental (song_genre 12).

Then I would like them inserted into my table (songs_genre) as :

PHP Code:
song_id song_genre
|   5
|  12