How can I update my genre list?

I have one table with different music genres called cat_tbl
In this one I have cat_id and category (which is a lot of different music styles)

Then I have one table called artist_tbl where I have the info about an artist.
artist_id and artist_name and so on…

Then I have a third table called artist_genre
This is where I store the genres that a connected to one artist
artist_id and genre_id

In this third table there might be more than one genre connected to one artist.
So, artist_id 5 can have several genres. Maybe genre_id 3 (blues) and genre_id 5 (jazz).
And who knows, maybe instrumental as well.

All this is made from a from where the genres are shown as checkboxes.
And this is working fine.

Now to my problem.

When I want to update one artist and change the genres I don’t know how to do it at all.

I want my checkboxes to be marked if they are selected before.
But of course updated if I change this or add one or remove one.

How should I do this. I’m really bad with arrays…

If you’re updating an artist and the genres then you could run a update query to update the artist details and run a separate insert query to update the genres for that artist. Will the genre updates only ever be adding new genres for an artist?

What database server software are you using?
What extension are you using to access MySQL from PHP?

Well, probably new genres will be added. I’m using Dreamweaver and phpmyadmin.
I just don’t get it how to update the artist_genre table. I guess it have to look for matches there and mark those as chosen. Hard to see the complete vision…

Well, now I solved it in my own special way, but it works. In my update page I list the checkboxes and genres. Within this loop I look for the user and genre in the artist_genre table. If it finds a result it sets the checkbox variable to yes. And when I update my page, which is at the top of my script, it deletes all rows with this artist in the artist_genres table and the next step it insert all the genres into the table. All other areas on my page are updated instead.

Not sure if it’s the right way or the best way, but I made it work in 15 mins and it works. So, I guess it’s ok.
Sometimes I just have to write about my thoughts and get inout from others… and along the way something pops up. Usually in the middle of the night when I’m not close to my computer.

But… what a relief when things work. It makes me happy and a bit proud.