imimin Posted March 31, 2009 Share Posted March 31, 2009 * Edit post * Delete post * Report this post * Reply with quote More than one term in category field??? Postby imimin on Tue Mar 31, 2009 3:49 pm I am setting up a SQL query that will be used to filter search results with a WHERE clause. In my MySQL DB, I have set up a "cat" column. Is there a way to enter more than one term in the cat field so I can give each row more than one category (such as 'child,solid')? I tried using an "," and ";" delimiter, but neither worked. It seems to only work if I have only one category in the cat field. Thanks in advance for any help! Gary Quote Link to comment https://forums.phpfreaks.com/topic/151981-more-than-one-term-in-category-field/ Share on other sites More sharing options...
pudge1 Posted March 31, 2009 Share Posted March 31, 2009 I don't know exactly what you mean but try making like $category = $category1 . ' ' . $category2 . Instead of trying to write to it twice. I don't know if I completely understand what you are saying though. Quote Link to comment https://forums.phpfreaks.com/topic/151981-more-than-one-term-in-category-field/#findComment-798157 Share on other sites More sharing options...
Maq Posted March 31, 2009 Share Posted March 31, 2009 Instead of storing the results delimited by a character just make a new record for each one with the same category. You can use an auto-incremented id to identify them uniquely. You should read more into Database normalization. Quote Link to comment https://forums.phpfreaks.com/topic/151981-more-than-one-term-in-category-field/#findComment-798194 Share on other sites More sharing options...
imimin Posted April 1, 2009 Author Share Posted April 1, 2009 I am sorry for my elementary questions or if I am not using proper terminology, my knowledge of DBs is fairly basic. I appreciate any help you can give me as I am learning. What I am saying is I have a series of products. Some of the products have more than one category. I have one row for each product and I have a SINGLE category field (cat). I would like to be able put more than one category in the the my 'cat' field either separated by a space, comma or something that is permissible in a database field. I will be "searching" that filed with a WHERE clause and populating a web page with the results. Pudge1, I am not sure what you mean by "$category = $category1 . ' ' . $category2 . Instead of trying to write to it twice"? Do you mind explaining? Maq, when you say "make a new record for each one with the same category" do you mean make duplicate rows for each product with various categories and only change the record by giving it a different category? For example, if product number '123' has 3 possible categories (style, color, size), I make 3 identical rows for product number '123' with the only difference in the rows being the value of the category in the 'cat' field (style, color, size)? Thanks again guys for your help, I REALLY appreciate it! Gary Quote Link to comment https://forums.phpfreaks.com/topic/151981-more-than-one-term-in-category-field/#findComment-798744 Share on other sites More sharing options...
fenway Posted April 2, 2009 Share Posted April 2, 2009 I would like to be able put more than one category in the the my 'cat' field either separated by a space, comma or something that is permissible in a database field. No. I make 3 identical rows for product number '123' with the only difference in the rows being the value of the category in the 'cat' field (style, color, size)? Yes. Quote Link to comment https://forums.phpfreaks.com/topic/151981-more-than-one-term-in-category-field/#findComment-799329 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.