Results 1 to 3 of 3

Thread: Extracting Depending While Loop From Mysql

  1. #1
    Join Date
    Nov 2010
    Posts
    115
    Thanks
    27
    Thanked 0 Times in 0 Posts

    Default Extracting Depending While Loop From Mysql

    Hi All,

    I am having a flow where my pre-defined members will join other new members into my site. Now i want to know pre-defined member joinees. For example "A" joined "B" and "C". B also joined "D, E, G" Members and "C" joined "H, F, L members. Now through query i need to know who all joined because of "User A"


    This is my table

    id, username, introducer_id

    1 user1, 9 (admin created this is predefined member)
    2, user2, 1
    3, user3, 1
    4, user4, 2
    5, user5, 3
    6, user6, 2
    7, user7, 3
    8, user8, 3
    9, user9, 2
    10, user10, 3
    11, user 11, 5
    12, user 12, 6
    13, user 13, 6

    14, user15, 23(admin created this is predefined member)
    15, user 16, 14

    16, user 18, 12

    Now if u see above, all the users are having a loop from "user 1". I want to know how can i get the total tree structure for "User 1 joinees"


    <?php

    $id = ""

    $sql3 = mysql_query("select * from member where introducer_id = '1' ");

    while($result3 = mysql_fetch_array($sql3))
    {
    $id = $result['id'];
    echo $result['username'];


    $sql4 = mysql_query("select * from member where introducer_id = $id ");

    while($result4 = mysql_fetch_array($sql4))
    {

    echo $result['username']; // with this i am able to get only user 2 and 3 but i not getting members joined through 2 and 3 users. how can i get it.

    }
    }
    ?>

    I am struck with this since yesterday, can anyone help me how to solve this issue

  2. #2
    Join Date
    Nov 2010
    Posts
    115
    Thanks
    27
    Thanked 0 Times in 0 Posts

    Default

    Issue solved

    Can't i post thanks for myself

  3. #3
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    Glad to hear it...

    If this thread is finished, please set it to resolved.
    You can do this by editing the first post within the thread - Pressing go advanced - Then where it says no prefix, selecting resolved then save.


    Also, for future reference -

    Please use the forum's bbcode tags to make your post more readable:

    for php code............[php] <?php /* code goes here */ ?> [/php]
    for html...............[html] <!-- markup goes here -->.....[/html]
    for js/css/other.......[code] code goes here................[/code]

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
  •