asanti Posted September 13, 2014 Share Posted September 13, 2014 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. Link to comment https://forums.phpfreaks.com/topic/291052-php-multiselect-process-from-different-tables/ Share on other sites More sharing options...
Barand Posted September 13, 2014 Share Posted September 13, 2014 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" Link to comment https://forums.phpfreaks.com/topic/291052-php-multiselect-process-from-different-tables/#findComment-1491011 Share on other sites More sharing options...
asanti Posted September 13, 2014 Author Share Posted September 13, 2014 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? Link to comment https://forums.phpfreaks.com/topic/291052-php-multiselect-process-from-different-tables/#findComment-1491012 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.