943,866 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 3058
  • ASP RSS
Jun 6th, 2005
0

Database and ASP loops and hierarachal Data

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
whitmarshdaniel is offline Offline
2 posts
since Jun 2005
Jun 8th, 2005
0

Re: Database and ASP loops and hierarachal Data

Seem you are working on multi-level marketing chart!! :cheesy:
You can use looping function to call database repeatedly:

ASP Syntax (Toggle Plain Text)
  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 ...
Reputation Points: 10
Solved Threads: 7
Posting Whiz in Training
zippee is offline Offline
294 posts
since Jan 2005
Jun 8th, 2005
0

Re: Database and ASP loops and hierarachal Data

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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
whitmarshdaniel is offline Offline
2 posts
since Jun 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: Buttons
Next Thread in ASP Forum Timeline: CDOSYS mail in win 2003





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC