PDA

View Full Version : how to get this display in asp?


NinjaTurtle
08-06-2002, 05:59 AM
dear

i have 2 tables: Category & Product

the database structure is:

Category
=======
categoryID
categoryName

Product
=======
categoryID
productID
productName

*categoryID in Product table is link to Category table.

And now i want the record displayed by category, the format is:

categoryID - categoryName
------------------------------------
Product Name
Product Name
Product Name
Product Name


example:

C0001 - Computer:
-------------------------
CPU
Harddisk
Mouse

C0002 - Fruit:
------------------------
Watermelon
Apple
Orange
Durian

C0003 - Car:
------------------------
no record.

P/S : I'm using ASP and SQL Server 2000.... how?

raf
08-06-2002, 08:03 AM
I would use a loop where I create
- a recordset for each categorie. (using a select query with an innner join and the categoryID as a condition)
- then build up the table (using the fields in that recordset)
- then close the recordset and set it to nothing
- categoryID = categoryID + 1 (to create the next recordset in your loop)

Does this make any sense ? Let us know if you need some further help.

Mhtml
08-06-2002, 08:07 AM
I'd do something similar to that as well, using a string to add a number greater then the initial in the variable as it gets looped it'll keep changing the number.

whammy
08-08-2002, 12:16 AM
You can just do this with a SQL Statement:


Category
=======
categoryID
categoryName

Product
=======
categoryID
productID
productName

*categoryID in Product table is link to Category table.

And now i want the record displayed by category, the format is:

categoryID - categoryName
------------------------------------
Product Name
Product Name
Product Name
Product Name



SELECT *
FROM TBL_Categories INNER JOIN TBL_Products ON TBL_Categories.CategoryID = TBL_Products.CategoryId;


That's just a starter hint, how complicated you want to get is up to you - but this stuff is really pretty simple.

NinjaTurtle
08-09-2002, 02:24 AM
ok... thanks