The right way to implement multiple selects from database data (list menu or radio button?)
I am making a website that will show night club revelers events and night establishments in a big city. Events could number in the hundreds.
A user should be able to add certain details when adding their event on the site e.g.(in the events table) event_name, event_description, event_date, event_photo_url etc.
I want users to be able 开发者_运维问答to search or find certain events or establishments based on interests or music genre. I have an interest table and a genre table in MySQL:
interests table
interest_id interest-name
1 Shoot Pool
2 Karaoke
3 Lounge
4 Live Band
5 Dance
6 Watch Sports
genre table
genre_id genre_name
1 Hip Hop
2 Soul
3 Reggae
4 Pop
5 Bangra
6 Rock
7 House
8 Country
9 Gospel
10 Carribean
11 Bongo
12 Genge
13 Mugithi
14 Dholuo
15 Kamba
16 Classical
17 Childrens
18 Latin
19 Jazz
20 Musicals
21 Middle Eastern
I have 2 other tables to link events with genres and events with interests ie;
event_genre table
event_genre_id
event_id
genre_id
and event_interest table
event_interest_id
event_id
interest_id
An establishment or event can have more than one interest e.g a club where one can play pool and watch the game. The same goes with music genres. A wide variety of music can be played in an establishment or event. A user whould be able to make multiple selects from genres and interests. My question is, do I have drop down list menus for each of the interests and genres? Can I have multiple selects for a drop down list menu and/or radio buttons? Is there a better way of implementing what I need?
I would go with a mess of checkboxes. The user would be able to check all of the interests or whatever that they are interested in. To process this you would just build a list of checked values and then pass that list into the query to filter the results. Make sense?
You could do two list boxes. This would allow you to select multiple genres and multiple interests in two simple controls which would save realestate and allow you to easily display and sort the available selections...
then on your server side you would just have to parse the values to build your query... THAT will probably be the hard part.
your value will more likely be returned as an array... not sure how that all works in php, but you would split your items down to an array object and basically loop through them.
you would then add AND genre = arItem(x) to your query and the same with interests.
精彩评论