Jump to content

Php multiselect process from different tables


asanti

Recommended Posts

I have this 3 tables


  • users (id_user)
  • music_styles (id_style, style) ex. (1) - (Blues)
  • user_styles (id_user, id_style)

I'm trying to create a form in which the user ($user = $_SESSION['id_user']) chooses through a multiple select the styles of preference to store them in the database using mysqli statements.


If the styles prefered are selected they should be displayed in the select input later, how can i accomplish this?


Thanks.


When you create the selection dropdown for music styles, use

SELECT ms.idstyle
    , style
    , id_user
FROM music_styles ms
    LEFT JOIN user_styles us
    ON ms.id_style = us.id_style AND us.id_user = $user

Those styles with a user id should be marked as "selected"

When you create the selection dropdown for music styles, use

SELECT ms.idstyle
    , style
    , id_user
FROM music_styles ms
    LEFT JOIN user_styles us
    ON ms.id_style = us.id_style AND us.id_user = $user

Those styles with a user id should be marked as "selected"

 

Thanks Barand, what about the db process? 

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.