Database and ASP loops and hierarachal Data

Please support our ASP advertiser: 50% off 6 Months Dedicated Server Hosting from 1&1!
Reply

Join Date: Jun 2005
Posts: 2
Reputation: whitmarshdaniel is an unknown quantity at this point 
Solved Threads: 0
whitmarshdaniel whitmarshdaniel is offline Offline
Newbie Poster

Database and ASP loops and hierarachal Data

 
0
  #1
Jun 6th, 2005
I have a employee table that includes there username and the username of there manager.

In one section of the site i need to be able to grant access to only people within certain chains. for example

at the moment when a user is logged on i do an sql call that says select * from ... where line_man_id = session (myId) that will then find all my staff.

i need to take this one step futher and work out who is there staff if any. for example i am incharge of robert and andrew, and andrew is in change of craig and pete.

I need to see all the data for all these people, andrew needs to see data for craig and pete and so on.....

Any Help, much appreciated..

Dan
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: Database and ASP loops and hierarachal Data

 
0
  #2
Jun 8th, 2005
Seem you are working on multi-level marketing chart!! :cheesy:
You can use looping function to call database repeatedly:

  1. ' user A login
  2. userid = Request("userid")
  3. ' query database for user A
  4. counter = 1
  5. select username from ... where user_id = "&userid&"' "
  6. ...
  7. While Not RS.EOF
  8. downline = RS("username")
  9. response.write "staff: " & downline
  10. counter = counter +1
  11. RS.MoveNext
  12. WEND
  13.  
  14. For x = 1 to counter
  15. ' repeat the database query here
  16. ' ...
  17. Next
  18.  
  19. 'if you are going down further, repeat the looping
Alternatively you may use array function to store "downline" name and query the database using
user_id = "&staff[0]&"' OR user_id = "&staff[1]&"' OR ...
Ecommerce-Web-Store.com Building Your e-Business.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2
Reputation: whitmarshdaniel is an unknown quantity at this point 
Solved Threads: 0
whitmarshdaniel whitmarshdaniel is offline Offline
Newbie Poster

Re: Database and ASP loops and hierarachal Data

 
0
  #3
Jun 8th, 2005
how do i kno how many loops i need...

for example....


There is one table that has 6 fields one of which is Userid, another deptid and another is linemanid

so dan could be

userid=134
deptid=2
linemangerid=123

dan could have staff...

dave

userid=158
deptid=2
linemangerid=134

rob

userid=162
deptid=2
linemangerid=134

... rob could have staff

jon

userid=198
deptid=2
linemangerid=162

Andy

userid=205
deptid=2
linemangerid=162

Dan needs to see all these people, Rob can see jon and andy, and andy and jon can just see their own

so the start point would be

select * from table where linemanagerid=session("userid")

so.. for dan this would return dave and rob. so i now need to work out how dan can see jon and andy through rob.. and if jon and andy were line managers thier people, so the loop could be very long of very short...

does that make any more sense?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 2984 | Replies: 2
Thread Tools Search this Thread



Tag cloud for ASP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC