Array help and Sessions

Results 1 to 2 of 2

Thread: Array help and Sessions

  1. #1
    Join Date
    Dec 1969

    Default Array help and Sessions

    Ok I have read a lot on this but I can not seem to grab it in my mind. This is what I am trying to do.<BR><BR>You load up the page and a Session starts with a empty array. You search for some parts, a page of parts from you seach loads up. There is a link that says add to list. You click on this link and it saves that part/s record ID and database table name into the array,the array is saved back into the session. You are then redirected back to the start of the search page incase you would like to search for more parts. You search for another part click on the add link and that parts&#039; record number and table name are added to the session array, and so on.<BR><BR>The goal is to pull this info. from the database and list it on the order page when the users is ready to send the E-mail away to oder his/hers parts.<BR>That&#039;s it.<BR><BR>What I have in global.asa is this<BR>-----------------------------------------------------------------<BR>&#060;SCRIPT RUNAT=server LANGUAGE="VBScript"&#062;<BR><BR>sub Application_OnStart()<BR><BR><BR><BR>end sub<BR><BR><BR>sub Session_OnStart<BR><BR>Dim cartArray()<BR>Dim cartMaxUsed<BR>cartMaxUsed = -1<BR>Session("cartArray") = cartArray<BR>Session("cartMaxUsed") = cartMaxUsed<BR>end sub<BR><BR>&#060;/SCRIPT&#062;<BR><BR>----------------------------------------------------------------<BR><BR>The Code I have inserted into my search page is this...<BR><BR>&#060;% If Request.QueryString("add") = "yes" Then<BR> Dim cartArray<BR> Dim cartMaxused<BR><BR><BR> cartArray = Session("cartArray")<BR> cartMaxUsed = Session("cartMaxUsed")<BR> cartMaxUsed = cartMaxUsed+1<BR> Response.Write cartMaxUsed<BR><BR> Redim Preserve cartArray(cartMaxUsed)<BR><BR><BR> cartArray(cartMaxUsed) = Request.QueryString("table_name") & Request.QueryString("rec_ID")<BR><BR><BR> for i = 0 to UBound(cartArray,1)<BR> Response.Write cartArray(i)<BR> next<BR> Session("cartMaxUsed") = cartMaxused<BR> Session("cartArray") = cartArray<BR><BR>End If<BR>%&#062;<BR><BR><BR>As you can see I know very little about arrays with two demsions. If any of you could help I would be in your debt. I find arrays a hard thing to learn for some reason. If any of you know of a site that explains 2D arrays in simple terms I would love to know it<BR><BR>Thanks for you help in Advance and I hope my code did not hurt your head to much.<BR><BR>Stephen

  2. #2
    Join Date
    Dec 1969

    Default RE: Array help and Sessions

    1. Design question - why do you have different tables for your parts? That sounds like a DB design problem.<BR><BR>2. Answer - you have not created a 2d array.<BR><BR>sub Session_OnStart<BR>Dim cartArray()<BR>ReDim cartArray(1,0) &#039;2d array<BR>Session("cartArray") = cartArray<BR>end sub<BR><BR>&#039;on your page:<BR>&#060;% If Request.QueryString("add") = "yes" Then<BR>Dim cartArray<BR>Dim iBound<BR><BR>cartArray = Session("cartArray")<BR>iBound = UBound(cartArray,2)<BR>Response.Write iBound<BR><BR>Redim Preserve cartArray(1,iBound + 1)<BR><BR><BR>cartArray(0,iBound) = Request.QueryString("table_name")<BR>cartArray(1,i Bound) = Request.QueryString("rec_ID")<BR><BR><BR>for i = 0 to UBound(cartArray,1)<BR>Response.Write "Table: " & cartArray(0,i)<BR>Response.Write ", ID: " & cartArray(1,i) & vbCrLf<BR>next<BR><BR>Session("cartArray") = cartArray<BR><BR>End If<BR>%&#062;<BR><BR>That should work. Give it a run and see...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts