php - How do I save the values of checkboxes in a form into a single MySQL field? -


I have a form where I have many musical genres, an artist can sing in many styles. I have put styles in the checkbox, now I need to store the checkbox values ​​in a field.

Can anyone help me with some code snippets because I'm new to programming?

In general, you should not have to do this, your database will not be, and this should be the question It would be difficult to create.

If you have a table named artists , then it would be better to have a table named Styles . Then you can define the relationship between the artists and the styles of any other table, artist_gent , in the table in which any artist_id and a genre_id Will hold. You may still be able to have many styles for the same artist. For example, consider the table structure defined below:

  table artist ------ ------- artist_id name surname 1 alicia keyes 2 maria cherry ... table Genres ------------ Genior_ID Name 1 R & B2 Pop 3 Hip Hop 4 Dance ... Table Artists_genres ------------------- In this case, you will be able to create simple questions like:  
 - artist_id genre_id 1 1 2 1 3 2 1 2 2 2 4 ...  

Select Artists Artists, artist artists Join Artists Artists (Artists Artists Artists Artists = Artists) on Artists. ON (genres.genre_id = artists_genres.gen Re_id) WHERE genre.name = 'pop';

It would be very difficult to achieve the above if your artist's style is stored in the same area in the artists table, in addition to the difficulty, It may be slow and inefficient, especially if you have many records.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -