imimin Posted May 11, 2009 Share Posted May 11, 2009 Does anyone have any ideas on this: Can I put more than one category in a "cat" field (MySQL database) separated by commas or another appropriate delimiter and call one or more categories by a link such as: http://patternsofjoy.com/gallery.php?cat=adult&cat=child (or some other format) I really DON'T want to have to create multiple rows of the same data with the only difference being different category data. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/157722-multiple-categories-in-one-cat-field/ Share on other sites More sharing options...
jackpf Posted May 11, 2009 Share Posted May 11, 2009 If you wanted the same key in the query string, you'll have to preceed it with [] so that PHP puts it into an array... Quote Link to comment https://forums.phpfreaks.com/topic/157722-multiple-categories-in-one-cat-field/#findComment-831827 Share on other sites More sharing options...
fenway Posted May 11, 2009 Share Posted May 11, 2009 I really DON'T want to have to create multiple rows of the same data with the only difference being different category data. Yes, you really DO -- that's exactly how this should be represented in the database. Quote Link to comment https://forums.phpfreaks.com/topic/157722-multiple-categories-in-one-cat-field/#findComment-831848 Share on other sites More sharing options...
Daniel0 Posted May 11, 2009 Share Posted May 11, 2009 http://www.google.com/search?q=many+to+many+relationship Quote Link to comment https://forums.phpfreaks.com/topic/157722-multiple-categories-in-one-cat-field/#findComment-831851 Share on other sites More sharing options...
jackpf Posted May 11, 2009 Share Posted May 11, 2009 Hmm...I suppose you could use some sort of mind bending join using SUBSTRING_INDEX() if you really wanted to Quote Link to comment https://forums.phpfreaks.com/topic/157722-multiple-categories-in-one-cat-field/#findComment-831856 Share on other sites More sharing options...
fenway Posted May 11, 2009 Share Posted May 11, 2009 Hmm...I suppose you could use some sort of mind bending join using SUBSTRING_INDEX() if you really wanted to Oh, there are plenty of ways to workaround this... they're just all bad ideas. Quote Link to comment https://forums.phpfreaks.com/topic/157722-multiple-categories-in-one-cat-field/#findComment-831873 Share on other sites More sharing options...
imimin Posted May 13, 2009 Author Share Posted May 13, 2009 I suppose you could use some sort of mind bending join using SUBSTRING_INDEX() if you really wanted to What do you mean by this and how would I proceed? And Oh, there are plenty of ways to workaround this... they're just all bad ideas. Why is it a bad idea? Quote Link to comment https://forums.phpfreaks.com/topic/157722-multiple-categories-in-one-cat-field/#findComment-832962 Share on other sites More sharing options...
xtopolis Posted May 13, 2009 Share Posted May 13, 2009 Performance wise, it sucks. Having to read through each CSV entry, parsing the string and determining if it is or isn't in a category... Changing/updating/deleting the categories in a csv method is semi unreliable. Why risk changing references to similar things such as "hat" and "chat", when you can edit them individually in one place? If you had a few rows that had csv categories like "house, hat, baseball" and another "school, chat, fire"... I would be skeptical that EVERY time would would perfectly type a mysql query to update only things that are == hat, rather than %hat or something similar. Take fenway's advice, it's good advice. Quote Link to comment https://forums.phpfreaks.com/topic/157722-multiple-categories-in-one-cat-field/#findComment-832982 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.