looped through records that = a value

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default looped through records that = a value

    i have a recordset that has values 1,2,3 in an field "intarea"

    my questions is how do i loop through all the records that = 1 then loop
    through all records that = 2

    i want to do this rather than creating 3 seperate recordsets is this
    possible ?

    adam


    ceaseanddesist Guest

  2. Similar Questions and Discussions

    1. can't get flash to loop through looped info from php
      I have php using a for loop to gather sets of info from a mysql database and then send it over to flash. I can't get Flash to loop through it and...
    2. Looped Array Element Deletion
      I want to loop through a structure of arrays using CFScript to delete an element in the same position of each array. Here is a snipet of code I...
    3. free looped audio every week
      FYI, GreatBigMedia.com is giving away a free audio loop every week that you can use for your flash projects. Its worth checking out.
    4. My looped MP3 is not looping!
      Hello I have an MP3 that I am using as background music for a Director file. I have clicked on the item in the cast and checked the "Loop" box...
    5. looped cloud animation
      hi tht is the problem of loading u hav to add preloader i had seen ur movie after loading all frames its working properly u add foll...
  3. #2

    Default Re: looped through records that = a value

    Use your order by clause
    ORDER BY intarea, <your existing order by list>

    Then, before using each record, make sure the value of intarea hasn't
    changed.

    "ceaseanddesist" <poorleno@ukip.com> wrote in message
    news:d6s24b$ndh$1@forums.macromedia.com...
    >i have a recordset that has values 1,2,3 in an field "intarea"
    >
    > my questions is how do i loop through all the records that = 1 then loop
    > through all records that = 2
    >
    > i want to do this rather than creating 3 seperate recordsets is this
    > possible ?
    >
    > adam
    >

    Lionstone Guest

  4. #3

    Default Re: looped through records that = a value

    lionstone thanks for the reply im using the following logic ( correct me if
    im wrong ) however it just returns all irrelevant of the intmaincatid and
    then a Either BOF or EOF error .. any suggestions ?

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <!--#include file="Connections/website.asp" -->
    <%
    Dim rspages
    Dim rspages_numRows

    Set rspages = Server.CreateObject("ADODB.Recordset")
    rspages.ActiveConnection = MM_website_STRING
    rspages.Source = "SELECT intid, intmaincatid, intsubcatid, strpagename FROM
    dbo.tblpages"
    rspages.CursorType = 2
    rspages.CursorLocation = 2
    rspages.LockType = 1
    rspages.Open()

    rspages_numRows = 0
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>

    <body>
    About us
    <%
    While NOT rspages.EOF AND rspages.Fields.Item("intmaincatid").Value = "1"
    %>
    <%=(rspages.Fields.Item("strpagename").Value)%>
    <%
    rspages.MoveNext()
    Wend
    %>
    Campaigns
    <%
    While NOT rspages.EOF AND rspages.Fields.Item("intmaincatid").Value = "2"
    %>
    <%=(rspages.Fields.Item("strpagename").Value)%>
    <%
    rspages.MoveNext()
    Wend
    %>


    </body>
    </html>
    <%
    rspages.Close()
    Set rspages = Nothing
    %>


    "Lionstone" <HIDElionstoneHIDE@HIDEhush.com> wrote in message
    news:d6snml$ss3$1@forums.macromedia.com...
    > Use your order by clause
    > ORDER BY intarea, <your existing order by list>
    >
    > Then, before using each record, make sure the value of intarea hasn't
    > changed.
    >
    > "ceaseanddesist" <poorleno@ukip.com> wrote in message
    > news:d6s24b$ndh$1@forums.macromedia.com...
    >>i have a recordset that has values 1,2,3 in an field "intarea"
    >>
    >> my questions is how do i loop through all the records that = 1 then loop
    >> through all records that = 2
    >>
    >> i want to do this rather than creating 3 seperate recordsets is this
    >> possible ?
    >>
    >> adam
    >>
    >
    >

    ceaseanddesist Guest

  5. #4

    Default Re: looped through records that = a value

    You need to add ORDER BY to your query in the recordset.
    rspages.Source = "SELECT intid, intmaincatid, intsubcatid, strpagename FROM
    dbo.tblpages ORDER BY intmaincatid"

    If the catid is an integer (which I'm assuming from the "int" at the
    beginning), no need to compare it to a string. Instead:
    <%
    While NOT rspages.EOF AND rspages.Fields.Item("intmaincatid").Value = 1
    %>
    I don't think it will fail when compared to "1" instead of 1, but why take
    chances?

    Now, VBScript does something which drives a lot of programmers nuts - it
    doesn't short-circuit on boolean comparisons. That is, in the above
    statement, if rspages is, in fact, empty, it will still try to access the
    field "intmaincatid" even though the AND comparison is already false.
    You're forced to nest the comparisons to avoid EOF errors:

    <%
    If NOT rspages.EOF Then
    Do While rspages.Fields.Item("intmaincatid").Value = 1
    %>
    Do Stuff
    <%
    Loop
    End If
    %>


    "ceaseanddesist" <poorleno@ukip.com> wrote in message
    news:d6spm0$2rt$1@forums.macromedia.com...
    > lionstone thanks for the reply im using the following logic ( correct me
    > if im wrong ) however it just returns all irrelevant of the intmaincatid
    > and then a Either BOF or EOF error .. any suggestions ?
    >
    > <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    > <!--#include file="Connections/website.asp" -->
    > <%
    > Dim rspages
    > Dim rspages_numRows
    >
    > Set rspages = Server.CreateObject("ADODB.Recordset")
    > rspages.ActiveConnection = MM_website_STRING
    > rspages.Source = "SELECT intid, intmaincatid, intsubcatid, strpagename
    > FROM dbo.tblpages"
    > rspages.CursorType = 2
    > rspages.CursorLocation = 2
    > rspages.LockType = 1
    > rspages.Open()
    >
    > rspages_numRows = 0
    > %>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    > "http://www.w3.org/TR/html4/loose.dtd">
    > <html>
    > <head>
    > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    > <title>Untitled Document</title>
    > </head>
    >
    > <body>
    > About us
    > <%
    > While NOT rspages.EOF AND rspages.Fields.Item("intmaincatid").Value = "1"
    > %>
    > <%=(rspages.Fields.Item("strpagename").Value)%>
    > <%
    > rspages.MoveNext()
    > Wend
    > %>
    > Campaigns
    > <%
    > While NOT rspages.EOF AND rspages.Fields.Item("intmaincatid").Value = "2"
    > %>
    > <%=(rspages.Fields.Item("strpagename").Value)%>
    > <%
    > rspages.MoveNext()
    > Wend
    > %>
    >
    >
    > </body>
    > </html>
    > <%
    > rspages.Close()
    > Set rspages = Nothing
    > %>
    >
    >
    > "Lionstone" <HIDElionstoneHIDE@HIDEhush.com> wrote in message
    > news:d6snml$ss3$1@forums.macromedia.com...
    >> Use your order by clause
    >> ORDER BY intarea, <your existing order by list>
    >>
    >> Then, before using each record, make sure the value of intarea hasn't
    >> changed.
    >>
    >> "ceaseanddesist" <poorleno@ukip.com> wrote in message
    >> news:d6s24b$ndh$1@forums.macromedia.com...
    >>>i have a recordset that has values 1,2,3 in an field "intarea"
    >>>
    >>> my questions is how do i loop through all the records that = 1 then
    >>> loop through all records that = 2
    >>>
    >>> i want to do this rather than creating 3 seperate recordsets is this
    >>> possible ?
    >>>
    >>> adam
    >>>
    >>
    >>
    >
    >

    Lionstone Guest

  6. #5

    Default Re: looped through records that = a value

    cheers much appreciated

    adam

    "Lionstone" <HIDElionstoneHIDE@HIDEhush.com> wrote in message
    news:d6t0eq$dck$1@forums.macromedia.com...
    > You need to add ORDER BY to your query in the recordset.
    > rspages.Source = "SELECT intid, intmaincatid, intsubcatid, strpagename
    > FROM dbo.tblpages ORDER BY intmaincatid"
    >
    > If the catid is an integer (which I'm assuming from the "int" at the
    > beginning), no need to compare it to a string. Instead:
    > <%
    > While NOT rspages.EOF AND rspages.Fields.Item("intmaincatid").Value = 1
    > %>
    > I don't think it will fail when compared to "1" instead of 1, but why take
    > chances?
    >
    > Now, VBScript does something which drives a lot of programmers nuts - it
    > doesn't short-circuit on boolean comparisons. That is, in the above
    > statement, if rspages is, in fact, empty, it will still try to access the
    > field "intmaincatid" even though the AND comparison is already false.
    > You're forced to nest the comparisons to avoid EOF errors:
    >
    > <%
    > If NOT rspages.EOF Then
    > Do While rspages.Fields.Item("intmaincatid").Value = 1
    > %>
    > Do Stuff
    > <%
    > Loop
    > End If
    > %>
    >
    >
    > "ceaseanddesist" <poorleno@ukip.com> wrote in message
    > news:d6spm0$2rt$1@forums.macromedia.com...
    >> lionstone thanks for the reply im using the following logic ( correct me
    >> if im wrong ) however it just returns all irrelevant of the intmaincatid
    >> and then a Either BOF or EOF error .. any suggestions ?
    >>
    >> <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    >> <!--#include file="Connections/website.asp" -->
    >> <%
    >> Dim rspages
    >> Dim rspages_numRows
    >>
    >> Set rspages = Server.CreateObject("ADODB.Recordset")
    >> rspages.ActiveConnection = MM_website_STRING
    >> rspages.Source = "SELECT intid, intmaincatid, intsubcatid, strpagename
    >> FROM dbo.tblpages"
    >> rspages.CursorType = 2
    >> rspages.CursorLocation = 2
    >> rspages.LockType = 1
    >> rspages.Open()
    >>
    >> rspages_numRows = 0
    >> %>
    >> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    >> "http://www.w3.org/TR/html4/loose.dtd">
    >> <html>
    >> <head>
    >> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    >> <title>Untitled Document</title>
    >> </head>
    >>
    >> <body>
    >> About us
    >> <%
    >> While NOT rspages.EOF AND rspages.Fields.Item("intmaincatid").Value = "1"
    >> %>
    >> <%=(rspages.Fields.Item("strpagename").Value)%>
    >> <%
    >> rspages.MoveNext()
    >> Wend
    >> %>
    >> Campaigns
    >> <%
    >> While NOT rspages.EOF AND rspages.Fields.Item("intmaincatid").Value = "2"
    >> %>
    >> <%=(rspages.Fields.Item("strpagename").Value)%>
    >> <%
    >> rspages.MoveNext()
    >> Wend
    >> %>
    >>
    >>
    >> </body>
    >> </html>
    >> <%
    >> rspages.Close()
    >> Set rspages = Nothing
    >> %>
    >>
    >>
    >> "Lionstone" <HIDElionstoneHIDE@HIDEhush.com> wrote in message
    >> news:d6snml$ss3$1@forums.macromedia.com...
    >>> Use your order by clause
    >>> ORDER BY intarea, <your existing order by list>
    >>>
    >>> Then, before using each record, make sure the value of intarea hasn't
    >>> changed.
    >>>
    >>> "ceaseanddesist" <poorleno@ukip.com> wrote in message
    >>> news:d6s24b$ndh$1@forums.macromedia.com...
    >>>>i have a recordset that has values 1,2,3 in an field "intarea"
    >>>>
    >>>> my questions is how do i loop through all the records that = 1 then
    >>>> loop through all records that = 2
    >>>>
    >>>> i want to do this rather than creating 3 seperate recordsets is this
    >>>> possible ?
    >>>>
    >>>> adam
    >>>>
    >>>
    >>>
    >>
    >>
    >
    >

    ceaseanddesist Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139