Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    358
    Thanks
    2
    Thanked 0 Times in 0 Posts

    how to get this display in asp?

    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?
    Last edited by NinjaTurtle; 08-06-2002 at 06:23 AM.
    Thanks.
    =====================================================
    From NinjaTurtle
    ++http://ohmygoh.blogspot.com|http://technology.ohmygoh.com++

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    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.
    Omnis mico antequam dominus Spookster!

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Code:
    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.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Posts
    358
    Thanks
    2
    Thanked 0 Times in 0 Posts
    ok... thanks
    Thanks.
    =====================================================
    From NinjaTurtle
    ++http://ohmygoh.blogspot.com|http://technology.ohmygoh.com++


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •