Re: [PHP] TR: Manipulating "categories" in a php database
- From: lists@xxxxxxxxx (Jim Lucas)
- Date: Tue, 30 Jan 2007 11:41:48 -0800
Tim wrote:
Hello all,What type of DB?
This is more of a conceptional question rather then a technical one.
I am developping an online catalog, the catalog is a standard
categorie/subcat/subsubcat system using the following logic in my database:
ouch...
cat_id cat_name
10 DVD
1010 DVD/Action
1020 DVD/Adventure
20 CD
2010 CD/Reggae
2020 CD/Electro
Up to now I enter the category id's manually from an administration console.
in mysql use auto_increment on the column and set it to PRIMARY KEY
I would like to be able to have my console automagically generate a cat_id
This will create a unique index for each row that is inserted to the table.
when my users add categories (so they don't have to bother with that aspectcreate a master_cat_id column and set that to the parent category for a given category, and then if the master_cat_id is not set, then you know that it is a top level/parent of a category.
of adding a category) and I would also like to be able to move a category up
or down in the way it displays on the page, as of now I am sorting by cat_id
How are you wanting the categories to be displayed? in a specific order or alphabetically?
I have been for a while trying to develop a logical scheme to be able to
generate the id's and change their cat_id to reflect a "new" position in how
it displays (displaying DVD/Action after DVD/Adventure for example I would
need to change the cat_id from 1010 to something above 1020 say 1021). This
is fine as I can test the previous elements cat_id and add or subtract 1 but
I get stuck when I have a cat_id say 1010 that I would want to put between
1011 and 1012. I'm having trouble developing the algorithm that would allow
this..
If you are wanting a specific order, you will have to create a new column for display order, then build a sorting feature into your app that would allow you to increase or decrease the display order
Would appreciate any "ideas" that may help me conclude this function in my
module.
Regards,
Tim Earl
--
Enjoy,
Jim Lucas
Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree.
- Rush
.
- References:
- TR: Manipulating "categories" in a php database
- From: "Tim"
- TR: Manipulating "categories" in a php database
- Prev by Date: Manipulating "categories" in a mysql database
- Next by Date: Re: [PHP] nested, referenced foreach & implicit current array pointer issues
- Previous by thread: TR: Manipulating "categories" in a php database
- Next by thread: nested, referenced foreach & implicit current array pointer issues
- Index(es):