SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Dynamic Rows

  1. #1
    - Michael - Bytecon's Avatar
    Join Date
    Mar 2004
    Location
    Ireland
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamic Rows

    I am having a problem because usually when I carry out mysql queries it is only in one table.

    But this time I will be using "SELECT * from $membername"

    My only problem is that this means that the rows will be different for each table because the member can chose to have different rows.

    So how can I parse this out attractively in php? It's easy for me if I know what rows I'm dealing with, I just do something like:

    NAME | AGE
    -----------------------------------
    $ROW['name'] | $ROW['age']

    But in this case I know what rows I'm dealing with. I will be parsing it out into a table and each row will be in a different column, how will It know how many columns there are, and the names of these columns. Also how will it know what to put into the $ROW[''] variable as this will be different for each member?

    As you can see I am slightly confused, mabye this isn't even possible but I think it may be.

    I would appreciate any help offered.

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    700
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    I would say that your problem is your database design. You shouldn't have different tables for different member. Use one table for all members which contains all common attributes. For the individual attributes you can use two additional tables with the layout

    attribute
    ----------
    attribute
    description

    memberAttributes
    ----------------
    Member -- foreign key to member table
    Attribute -- foreign key attribute table
    attributeValue


Bookmarks

Posting Permissions

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