SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Oct 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multi dimesional array

    Hi, Can anyone know that 4 dimensional arrays work in classic asp. because i didn't found any such example. I am struggling from 3 days for that. can anyone guide me please.

    I have created the request form and the results table to print the results. the form contains a drop-down list. if the form is complete then it should loop through the list of arrays and should match particular brand in drop-down list at which user selected one and then it should go through query and retrieve the results from database table and print in the separate html page table. "the problem is it should loop through the list of 4 dimensional arrays when user selects option in drop-down list and retrieve required results from database".

    <%
    if formComplete then

    'Declare some required variables
    Dim rs, strSQL, objConn

    'connected to database
    dbconnect

    Dim ArrResult
    Dim Brand_lookup(12,4,4,4)
    Brand_lookup(0,0,0,0) = "smr"
    Brand_lookup(0,0,0,1) = "sedan"
    Brand_lookup(0,0,0,2) ="5"
    Brand_lookup(0,0,0,3) = "suzuki"

    Brand_lookup(1,0,0,0) = "smi"
    Brand_lookup(2,0,0,0) = "suzukimini"
    Brand_lookup(3,0,0,0) = "6"
    Brand_lookup(4,0,0,0) = "Holden"

    Brand_lookup(0,0,1,0) = "tng"
    Brand_lookup(0,0,2,0) = "tata"
    Brand_lookup(0,0,3,0) = "14"
    Brand_lookup(0,0,4,0) = "Tata"



    strSQLscroll = "SELECT contentID, name, domain, url1, url2, url3, active FROM tblPosseContent_"& Request.Form("brand") &" WHERE (name LIKE '%Dealer%') OR (domain LIKE '%domain%') ORDER BY name"

    'Create recordset object
    Set rs = Server.CreateObject("ADODB.Recordset")
    'Create recordset using query
    rs.Open strSQL, objConn

    Dim i
    For i = 0 to UBound(Brand_Lookup)

    response.write("show values: " & Brand_lookup(i))

    do while rs.EOF

    ArrResult(Brand_lookup(i)) = (""& Request.Form("Brand") &"")
    i =i + 1
    loop
    Next

    %>

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    ASP works fine with multi-dimensioned arrays - see example code below. To YOUR issue - what error message are you getting, and against which line? I suspect it is:

    Dim ArrResult

    ... as this sets the variable as a Variant type, you then try to use it as an Array type without having made it an array ...

    ArrResult(Brand_lookup(i)) = (""& Request.Form("Brand") &"")

    ... You also try to look at an array value, but don't define exactly WHICH array element you want ...

    response.write("show values: " & Brand_lookup(i))

    ... I think you need to go back to basics on how to use arrays in ASP.

    https://www.google.co.uk/webhp?q=asp...ltidimensional

    Code ASP:
    <%
    Dim arr(1,1,1)
    arr(0,0,0)="000"
    arr(0,0,1)="001"
    arr(0,1,0)="010"
    arr(0,1,1)="011"
    arr(1,0,0)="100"
    arr(1,0,1)="101"
    arr(1,1,0)="110"
    arr(1,1,1)="111"
    Response.write arr(1,0,1)
    %>
    <p>HERE</p>
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Member
    Join Date
    Oct 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks siteguru. I am new to this programming. i have gone through that sites but one of my friend who is working as .net programmer, he said he didn't see 4 dimensional array, so i am very confused. one more thing i want to know is i have to the list of multidimensional arrays and the list have 128 array values. and can u please tell me i need to loop the list of arrays and match it with the option which user selected. so can you please give an example for that. i am very much confused. thanks in advance.

  4. #4
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It might be easier if you try to explain exactly what it is you are trying to achieve (use pseudo-code if necessary, and break it down into bite-size pieces) so we can advise on the best course of action.
    Ian Anderson
    www.siteguru.co.uk

  5. #5
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks like you have 4 pieces of data for each array item so why not something like this:


    Dim Brand_lookup(128,4)
    Brand_lookup(1,1) = "smr"
    Brand_lookup(1,2) = "sedan"
    Brand_lookup(1,3) ="5"
    Brand_lookup(1,4) = "suzuki"

    Brand_lookup(2,1) = "smi"
    Brand_lookup(2,2) = "suzukimini"
    Brand_lookup(2,3) = "6"
    Brand_lookup(2,4) = "Holden"

    ...

  6. #6
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Location
    OH, USA
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by webber123456 View Post
    Looks like you have 4 pieces of data for each array item so why not something like this:


    Dim Brand_lookup(128,4)
    Brand_lookup(1,1) = "smr"
    Brand_lookup(1,2) = "sedan"
    Brand_lookup(1,3) ="5"
    Brand_lookup(1,4) = "suzuki"

    Brand_lookup(2,1) = "smi"
    Brand_lookup(2,2) = "suzukimini"
    Brand_lookup(2,3) = "6"
    Brand_lookup(2,4) = "Holden"

    ...
    I do not think you need that multidimensional array in a first place...
    if you have dropdowns already, why not put values which you need tor your query in value from option?
    like
    <option value="smr">sedan</option>, or what ever you need?


Bookmarks

Posting Permissions

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