Help for query PHP MySQL

Discussion in 'PHP' started by salayhin, May 24, 2010.

  1. #1
    Hello,

    Please help me to fetch data from bottom member. here is a picture give below.

    [​IMG]

    I want to get all information within my network as picture shows using PHP MySQL

    Please help Me.

    Thanks
     
    salayhin, May 24, 2010 IP
  2. Trikun3

    Trikun3 Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'm not quite understanding what you want to achieve. Do you have a database schema already made?
     
    Trikun3, May 24, 2010 IP
  3. swiftnomad

    swiftnomad Active Member

    Messages:
    185
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    50
    #3
    SELECT * FROM dbname
     
    swiftnomad, May 24, 2010 IP
  4. salayhin

    salayhin Peon

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you for your reply.

    I have made a sample database only have user_ID (primary),Username, Referance_ID.

    Is this alright?

    I want when i click ones id all member of his/her network will be shown.As this picture you see that there is some level of member i actually want to fetch data from this levels.

    Thanks Again.
     
    salayhin, May 24, 2010 IP
  5. jawaidgadiwala

    jawaidgadiwala Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    hmm you are storing USER_ID(primary key), USER_NAME and REFERENCE_ID

    i think with reference id you means that under which user does the current user comes ??? if i am right then for the current scenario pseudo code will be like..

    first of all display all users like in pic and give a hyperlink to them as 'index.php?id=' . $user_id
    $user_id is fetched from database.... then when some one click on that user use the following query..

    $result=mysql_query('SELECT * FROM user_table where reference_id=' . $_GET['id'] );

    i hope you understood the logic....
     
    jawaidgadiwala, May 25, 2010 IP
  6. salayhin

    salayhin Peon

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hello,
    Thanks For reply.

    Actually i want to know how can i get the level of the user?
    On the picture second line of man is first level , third lne is second level...and so on.

    I want to know which user is my second level and which is in third level and so on...

    Please help me.

    Thanks
     
    salayhin, May 25, 2010 IP
  7. adamsinfo

    adamsinfo Greenhorn

    Messages:
    60
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #7
    SELECT level_field FROM user WHERE user_id=$id
     
    adamsinfo, May 25, 2010 IP
  8. salayhin

    salayhin Peon

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hello,

    Thanks for reply.

    But where i use level field in database?

    Would u please advice me for database?

    Thanks
     
    salayhin, May 25, 2010 IP
  9. salayhin

    salayhin Peon

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    When the new user add on my network direct referral will be in my first level and so on...
    How can i find second level, third level, fourth level and so on?

    Is that clear now?
     
    salayhin, May 25, 2010 IP
  10. Khusmair

    Khusmair Greenhorn

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #10
    Dear sakayhin yes you are right by default its will be on first level.

    for that you need to define these all levels on your website admin area, Please make the Edit member area and retrieve your all levels from database to drop down and from there you can change user levels on your wish or user request maybe its help.
     
    Khusmair, May 26, 2010 IP
  11. jawaidgadiwala

    jawaidgadiwala Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Now you clarified the requirement. So for this make another field 'level' in the table. By default it will be 1 if 'reference_id' is NULL but if there is any 'reference_id' then retrieve the level of the user having user_id equal to that reference_id and add 1 to that level. This will be the level of the new user... I hope you understood what i tried to tell....
     
    jawaidgadiwala, May 26, 2010 IP