|
Duplicate: SQL - how to store and navigate hierarchies
If I have a database where the client requires categories, sub-categories, sub-sub-categories and so on, what's the best way to do that? If they only needed three, and always knew they'd need three...
Started by johnny on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Table categories: id, title, parent_category_id id | title | parent_category_id ----+ + 1 | food.
|
|
Say on my old site I have one level categories of products, with one category being "BMW Cars".. inside of that, I have some products : "328i" , "M3", "M5", "X5"... so basically it is a big mix of everything - cause in the beginning we didnt separate ...
Started by jim on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
If 90% of the BMW's on your website are sedans and 10% SUV's, but 95% of your visitors are searching for SUV's instead of sedans then it may be more appropriate to redirect to SUV... .
Look at the percentages of visits.
Don't look at the percentages of cars.
|
|
I am displaying a list of categories in ASC order."OTHERS" is also one of the category. I need to display all categories in ASC ORDER and "OTHERS" in last .
This is done by using PHP and MYSQL.
TABLE STRUCTURE
tale name: categories
id categoryname 1 APPLE...
Started by Fero on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
SELECT * FROM categories ORDER BY Column1 ASC, Column2 ASC, Column3 DESC
You could try something like
SELECT * FROM Categories ORDER BY CASE WHEN Categorie = 'OTHERS' THEN 2 ELSE 1 END, Categorie
SELECT * FROM categories....
|
Ask your Facebook Friends
|
The category table looks like somewhat as below:
id -- name -- parent_id 1 -- Men -- 0 2 -- Women -- 0 3 -- Shirts -- 1 4 -- Half-sleeve -- 3 5 -- Full-sleeve -- 3
Relationship table:
Product_id -- Category Id 1 -- 2 2 -- 2 3 -- 4 ....
I can retrieve ...
Started by Wbdvlpr on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
MoreCats) { getProdsInCat($cats['cat_id']); } }
Assuming you can add an extra column to the categories
That way finding all the subcategories becomes one query:
SELECT id as CatId FROM categories WHERE path easy too:
SELECT count(p.id....
|
|
Do they have a table for all categories and another for all sub-categories (and another for the sub-sub-categories and so on), or what? How do all the levels go around communicating with each other?
I'm a noob getting started on a project that might have...
Started by Baby Diego on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
If there's a one to one you have Categories in multiple categories then you likely would have a normalized table structure whereby you have Categories to the product, ....
Exist in multiple categories" also alters the outcome.
|
|
My blog's main menu is made of the categories, displayed via the wp_list_categories function.
If i click on one of the categories, the current category is highlighted in the category menu, and the list of articles inside that category are listed. Everything...
Started by pixeline on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Also, are you sure the same code; $currentcategory = '¤t_category='.$myCat; } wp_list_categories('depth=1&title_li=&orderby=id&exclude.
Parent' isn't a valid argument for wp_list_categories.
|
|
Hi,
I have a category structure like this in WordPress (that is echoed with wp _ list _ categories):
Works Photos 1990-2000 Photo #1 Photo #2 Photo #3 2000-2010 Photo #1 Photo #2 Photo #3 Paintings Watercolor Painting #1 Painting #2 Oil paint Painting...
Started by Fred Bergman on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Javascript
element.parentNode.className = "highlighted";
....
Element.parentNode will do the trick.
If this is the case, you could use some javascript to set the style of the parent elements .
I am assuming that your list is composed of ul and li elements .
|
|
I use wp_list_categories() to get the list of all the categories and generate the navigation bar. Is there a way to order this categories in a particular order other than alphabetical ordering.
eg: Connect, News & Views, Q&A, Hello Startup, Startup 10...
Started by Saneef on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Hi @Saneef
I think following plugin is much simpler and easy to use:
http://wordpress.org/extend/plugins/order-categories/
You can use a really simple.
Order/ ) we can order categories in any order.
|
|
Hi,
I'm making list of items in categories, problem is that item can be in multiple categories. What is your best practice to store items in categories and how list all items within category and its child categories? I am using Zend Framework and MySQL...
Started by Irmantas on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
So, you have a hierarchy in the categories, yes? Is it one level (category and child category to list which items are in which categories:
SELECT I.* FROM Item I INNER JOIN Item_Category IC = 'MyCategory'
Or which ....
|
|
I need to grab all categories that don't have subcategories
1 ^--1.1 ^--1.2 ^--1.2.3 2 ^--2.1 3
In this example I would want to get [1.1], [1.2.3], [2.1] and [3].
My Categories table looks like this:
CategoryID | CategoryName | ParentID
I figure I should...
Started by ajbeaven on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
SELECT * FROM categories WHERE categoryID NOT IN (SELECT parentID FROM categories)
Try:
List<.
|