learningPHP1 Posted March 19, 2013 Share Posted March 19, 2013 Hello,I wrote a small script that basically displays 20 to 30 categories on a page which a user has the option toeither select one or multiple items from the list. For the sack of argument the user selected the following items from the list:Table-> tbl_category : ‘Green car’, ‘truck’, ‘Van’, ‘minivan’,’ laptop’, ‘iPhone’, ‘great value mixed nuts 80% peanuts’, ‘cup’Tables I have:Table-> tbl_userTable-> tbl_categoryWhat is the best practice in terms of saving the multiple selection:1.Do I create a field in tbl_user and save the selection or selections into that one field?2. Create a separate tbl_saveCategoreySelection and save them as individual records and link it to tbl_user? At the same time the saved category list will need to be searchable.Any help you can provide would be greatly appreciated.Thanks Link to comment https://forums.phpfreaks.com/topic/275860-best-practice-question-in-the-event-a-user-selects-multiple-itmes-from-a-category-lis/ Share on other sites More sharing options...
Barand Posted March 19, 2013 Share Posted March 19, 2013 definitely option 2 A separate table with columns : userID, categoryID, primary key (userID, categoryID) Link to comment https://forums.phpfreaks.com/topic/275860-best-practice-question-in-the-event-a-user-selects-multiple-itmes-from-a-category-lis/#findComment-1419560 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.