I got 3 tables:
+----Songs----+ +----Tags----+ +----s_in_tag----+
| id | | id | | id |
| title | | name | | song_id |
+-------------+ +------------+ | tag_id |
+----------------+
In table Songs I store a list of songs, table Tags have a list of tags, and table s_in_tag bind those 2 tables.
Let say i have in Songs:
- id => 1,
- title => song nr1.
In Tags:
- id => 1,
name => POP;
id => 2,
name => Rap;
id => 3,
- name => Classical.
And in s_in_tag:
- id => 1,
- song_id => 3,
- tag_id => 2
This means that song nr1 has tag Classical
Now the idea is to select a song, to get all records from s_in_tag for that song, and then to output a list of checkboxes with data from tags. I did all this, and i managed to show if a checkbox is selected or no, but how do i make the script which will allow me to add a tag, and then, if i want, to remove him? It does not work with $_POST['checkbox'] because when i remove a tag, i uncheck it.
Aucun commentaire:
Enregistrer un commentaire