Join records form same table

Discussion in 'PHP' started by WebRob, Mar 20, 2008.

  1. #1
    I have posted this last week but I received no responses so I am going to try and explain this better....

    I have a question that has been haunting me for days now.

    I have results from a mySQL database that I am exporting to a CSV. These records are sales form an eCommerce store (ZenCart).

    What happens is that attributes for each part of an order make a new row for each attribute. Like this:

    | order | attribute | attribute value |
    +-------+-----------+-------------+
    | 101 | name | bob |
    +-------+-----------+-------------+
    | 101 | address | 123 any street |
    +------+----------+---------------+

    I need the results to be in XML or CSV (XML is preferred) that has a structure like this:

    <order>
    <number>101</order>
    <attribute field=name>bob</attribute>
    <attribute field=address>123 any street</attribute>
    </order>

    OR:

    <order>
    <number>101</order>
    <name>bob</name>
    <address>123 any street</address>
    </order>

    or anything similar

    I have the SQL query done but formatting the output to be how I need is the hard part. Can someone help me or point me in the right direction?
     
    WebRob, Mar 20, 2008 IP
  2. RoscoeT

    RoscoeT Peon

    Messages:
    78
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What is your SQL? can you explain what you're trying to do a little better?

     
    RoscoeT, Mar 20, 2008 IP