Tim wrote:
Hello all,
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:
What type of DB?
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.
ouch...
I would like to be able to have my console automagically generate a cat_id
in mysql use auto_increment on the column and set it to PRIMARY KEY
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 aspect
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
create 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.
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..
How are you wanting the categories to be displayed? in a specific order
or alphabetically?
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php