rubing Posted April 10, 2008 Share Posted April 10, 2008 I have an html form which is submitted as a user profile. The form has a hobbies section where the user can select all their hobbies using html 'checkbox'. I'm trying to figure out the best way to process this info, since i might want to restrict news and updates from my site to people with certain hobbies later on. Currently all the hobby info comes from a checkbox array (e.g. <input name=hobbies[] ...), I guess I should just convert the array to a string and insert it into a collumn on the users' record? And then later when i want to SELECT people with certain hobbies just use the %LIKE% keyword? Does this seem like a reasonable way to go about it? Thanks for the help brothas and sistas. Link to comment https://forums.phpfreaks.com/topic/100476-checkbox-validation/ Share on other sites More sharing options...
obsidian Posted April 10, 2008 Share Posted April 10, 2008 Usually, for something you're going to be querying against later, you would want to have a joining table that has the individual hobby interests in it: Users: user_id username etc... Hobbies: hobby_id title description etc... User_Hobbies: user_id hobby_id With that kind of table structure, you could pull all users with a specific interest by just doing a query on the hobby index in the User_Hobbies table. This is much less intensive than using a LIKE on a text column since it won't require a full table scan to complete (especially if it's indexed correctly). In addition, your table structure is more normalized, too ;-) Link to comment https://forums.phpfreaks.com/topic/100476-checkbox-validation/#findComment-513811 Share on other sites More sharing options...
rubing Posted April 10, 2008 Author Share Posted April 10, 2008 That does sound a lot cleaner. And I guess I could even give them the option to add and define their own hobby category. Link to comment https://forums.phpfreaks.com/topic/100476-checkbox-validation/#findComment-513879 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.