Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • Last Modified:

Filtering Data From Multiple Recordsets?

I am currently working on a profile page that users will go to once they log in to our website. The profile page will show the users contact information, as well as show any additional items that are relavent to the user like outstanding orders, missing documents etc...

How I have this set up is, there is a table in the database that has all the user's info like name, pass, address, etc.. They login to the site and it validates it baised off that table. Then when they click on the profile link it takes them to the "Profile" page. Once they enter the the profile page I can get the recordset to filter based off of MM_Username and so that recordset loads just fine. But in the second, and third section I want to be able to show the records off a second and third recordset. Now in each table I have a field called salesrepcode that I would like to use to tie all off the records together. So Ideally the page will show just the records associated to that user. Can anyone help me figure out how I can filter the second and third recordsets?

Thanks in advance!

Section#1 Welcome User - Recordset#1 - Table Users
Section#2 Users Information, Address, phone, etc... Recordset#1 - Table Users
Section#3 Order History - Recordset#2 - Table SalesRecords
Section#4 Missing Paperwork - Recordset#3 - Table MissingDocs
1 Solution
awinsteadAuthor Commented:
Ok after spending hours looking this up I have figured out that I need to create a second Session Variable from my login page that will grab the value of whatever is in the SREP_CODE field. now thr problem I have is placing the new session Variable. Here is the code I am using on my login. Right now the code doesn't seem to send session to the new page. I must be doing something wrong but not sure as to what?

Login code:
<!--#include file="Connections/Main_DB.asp" -->
Dim Employee
Dim Employee_numRows

Set Employee = Server.CreateObject("ADODB.Recordset")
Employee.ActiveConnection = MM_Main_DB_STRING
Employee.Source = "SELECT * FROM Fullemployees"
Employee.CursorType = 0
Employee.CursorLocation = 2
Employee.LockType = 1

Employee_numRows = 0
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
If MM_valUsername <> "" Then
  set MM_rsUser = Server.CreateObject(MM_flag)
  MM_rsUser.ActiveConnection = MM_Main_DB_STRING
  MM_rsUser.Source = "SELECT Username, password"
  If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
  MM_rsUser.Source = MM_rsUser.Source & " FROM Fullemployees WHERE Username='" & Replace(MM_valUsername,"'","''") &"' AND password='" & Replace(Request.Form("pwd"),"'","''") & "'"
  MM_rsUser.CursorType = 0
  MM_rsUser.CursorLocation = 2
  MM_rsUser.LockType = 3
  If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
    ' username and password match - this is a valid user
    Session("MM_Username") = MM_valUsername
    session("svSaleRep") = Employee.fields.Item("SREP_CODE").value
    If (MM_fldUserAuthorization <> "") Then
      Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
      Session("MM_UserAuthorization") = ""
    End If
    if CStr(Request.QueryString("accessdenied")) <> "" And true Then
      MM_redirectLoginSuccess = Request.QueryString("accessdenied")
    End If
  End If
End If
I think you're heading in the right direction..,

However, you could ease the burden on yourself if you get all of the user info up front.

You have three tables that you are gather data from, correct?

So, let's say that once the user logs on you want to keep resident;

Real Name
Order History - last 5 orders
Missing Paperwork

When you construct your query you should be able to pull all of this data, now all you need to do is keep it in state.

Consider that Session Object are in fact associative array objects, and like arrays they can have multiple dimensions.

Session['username'] // identifies the username
Session['username']['RealName'] // identifies the real name of user (n)
Session['username']['address'] // identifies the address of user (n)
Session['username']['email'] // identifies the email address of user (n)
Session['username']['OrderHistory'] // identifies the order history of user (n), probably a string representing an array that can be parsed
Session['username']['MissingPaperWork'] // identifies the missing paperwork of user (n), again maybe a string representing an array

This may seem a little confusing at first but remember, looping through an array to get specific values is very straight forward.  It's those values that you can, in turn, use for conditions in other queries.

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now