Log in

View Full Version : Extracting Depending While Loop From Mysql



hemi519
08-15-2012, 09:02 AM
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

hemi519
08-15-2012, 11:16 AM
Issue solved

Can't i post thanks for myself :) :) :)

keyboard
08-16-2012, 01:02 AM
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 /* code goes here */ ?>
for html...............
<!-- markup goes here -->.....
for js/css/other.......
code goes here................