Posted 14 August 2006 - 11:32 PM
Posted 14 August 2006 - 11:41 PM
but different categories will be in different tables in the database
There is you problem. Why are different categories going into different tables? If product id's need to be unique, they really aught to be. Maybe you should look into database normalization techniques.
Posted 14 August 2006 - 11:45 PM
Posted 14 August 2006 - 11:52 PM
Posted 14 August 2006 - 11:54 PM
Posted 14 August 2006 - 11:55 PM
is there a better way?
Yes. Database normalization. At its simplest you would have a signle table something like...
CREATE TABLE products ( id INT PRIMARY KEY, title VARCHAR(80), cat INT )
This enables you to store all your products in a single table, all with a unique id, and all in there own catigories if required. To get the all products, you would simply query something like....
SELECT * FROM products GROUP by cat
Posted 14 August 2006 - 11:57 PM
how would i use a while loop to display links to all categories if it has a column with it in? i thought of it before
Well, how are you defining your categories?
Posted 15 August 2006 - 12:06 AM
and it would say like "PC" or "Printers" in it.
I need a page where it will display links to all the different categories so you can click it to show all items under that category.
Posted 15 August 2006 - 12:17 AM
In most shopping carts there's a separate table for category creation containing those ID's. Then, in your product table, you'd have a field for category and reference the proper category ID in that in order to assign the product to the right category. Your while loop would run through the product database and display the products as per category.
CREATE TABLE category ( id VARCHAR(80) PRIMARY KEY, title VARCHAR(80), )
Or something like that.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users