Separating results

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MRK

    Separating results

    I want to add a <p> after 10 results are given
    and do this in a loop after every 10 results.
    Here is my query and my current results code

    How would I modify this to add a <P> after
    every 10 results for ts?



    <%
    Response.Buffer = True
    Dim connStrx, rs, ss, ts, book1, verse1, chap1, bookopt
    connStrx = "Provider=Micro soft.Jet.OLEDB. 4.0; Data Source=" &
    Server.MapPath( "\data\kwm\kjv. mdb")
    Set rs = CreateObject("A DODB.Recordset" )
    Set ss = CreateObject("A DODB.Recordset" )
    Set ts = CreateObject("A DODB.Recordset" )

    rs.Open "select distinct booktitle, book from bibletable order by book ASC",
    connStrx, 3, 4
    If Not rs.EOF Then
    If Request.Form("S ubmit")="GO" Then
    bookopt = request.form("b ook")
    else
    bookopt=""
    end if
    While Not rs.EOF
    If trim(bookopt) = trim(rs("bookti tle")) then
    response.write "<option value='" & rs("booktitle" ) & "' selected>" &
    rs("booktitle" ) & "</option>"
    else
    response.write "<option value='" & rs("booktitle" ) & "'>" &
    rs("booktitle" ) & "</option>"
    end if
    rs.MoveNext
    Wend

    ELSE
    END IF
    rs.close
    set rs = nothing

    If len(bookopt)>1 Then
    ss.Open "select distinct chapter from bibletable where
    [bibletable.book title]='" & bookopt & "' order by chapter ASC", connStrx, 3,
    4
    If Not ss.EOF Then
    While Not ss.EOF
    chap1=ss("chapt er")
    response.write ss("chapter")

    ' here is where I want to create a <p> after every 10 results

    ts.Open "select * from bibletable where [bibletable.book title]='" &
    bookopt & "' and [bibletable.chap ter]=" & chap1 & " order by verse ASC",
    connStrx, 3, 4
    If Not ts.EOF Then
    While Not ts.EOF
    response.write " <font color=red>" & ts("verse") & "</font> " &
    ts("textdata") & " "
    ts.MoveNext
    Wend
    ts.close
    else
    end if
    ss.MoveNext
    Wend
    else
    end if
    end if
    %>


  • Curt_C [MVP]

    #2
    Re: Separating results

    outside the loop put in a variable (XX = 0)
    At that point in the loop you want the <P> do a:
    IF XX >= 10 then
    ..."<P>"....
    XX = 0
    ELSE
    XX = XX + 1
    END IF


    --
    Curt Christianson
    Owner/Lead Developer, DF-Software
    Site: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "MRK" <sdkngfksdnf> wrote in message
    news:udrfdc3XEH A.3516@TK2MSFTN GP09.phx.gbl...[color=blue]
    > I want to add a <p> after 10 results are given
    > and do this in a loop after every 10 results.
    > Here is my query and my current results code
    >
    > How would I modify this to add a <P> after
    > every 10 results for ts?
    >
    >
    >
    > <%
    > Response.Buffer = True
    > Dim connStrx, rs, ss, ts, book1, verse1, chap1, bookopt
    > connStrx = "Provider=Micro soft.Jet.OLEDB. 4.0; Data Source=" &
    > Server.MapPath( "\data\kwm\kjv. mdb")
    > Set rs = CreateObject("A DODB.Recordset" )
    > Set ss = CreateObject("A DODB.Recordset" )
    > Set ts = CreateObject("A DODB.Recordset" )
    >
    > rs.Open "select distinct booktitle, book from bibletable order by book[/color]
    ASC",[color=blue]
    > connStrx, 3, 4
    > If Not rs.EOF Then
    > If Request.Form("S ubmit")="GO" Then
    > bookopt = request.form("b ook")
    > else
    > bookopt=""
    > end if
    > While Not rs.EOF
    > If trim(bookopt) = trim(rs("bookti tle")) then
    > response.write "<option value='" & rs("booktitle" ) & "' selected>" &
    > rs("booktitle" ) & "</option>"
    > else
    > response.write "<option value='" & rs("booktitle" ) & "'>" &
    > rs("booktitle" ) & "</option>"
    > end if
    > rs.MoveNext
    > Wend
    >
    > ELSE
    > END IF
    > rs.close
    > set rs = nothing
    >
    > If len(bookopt)>1 Then
    > ss.Open "select distinct chapter from bibletable where
    > [bibletable.book title]='" & bookopt & "' order by chapter ASC", connStrx,[/color]
    3,[color=blue]
    > 4
    > If Not ss.EOF Then
    > While Not ss.EOF
    > chap1=ss("chapt er")
    > response.write ss("chapter")
    >
    > ' here is where I want to create a <p> after every 10 results
    >
    > ts.Open "select * from bibletable where [bibletable.book title]='" &
    > bookopt & "' and [bibletable.chap ter]=" & chap1 & " order by verse ASC",
    > connStrx, 3, 4
    > If Not ts.EOF Then
    > While Not ts.EOF
    > response.write " <font color=red>" & ts("verse") & "</font> " &
    > ts("textdata") & " "
    > ts.MoveNext
    > Wend
    > ts.close
    > else
    > end if
    > ss.MoveNext
    > Wend
    > else
    > end if
    > end if
    > %>
    >
    >[/color]


    Comment

    • Ray at

      #3
      Re: Separating results

      The simple way is to put in a counter like so (added code in uppercase):



      DIM I
      I = 1
      RESPONSE.WRITE "<p>"
      While Not ss.EOF
      chap1=ss("chapt er")
      response.write ss("chapter")

      ' here is where I want to create a <p> after every 10 results
      IF I = 10 THEN
      RESPONSE.WRITE "</p>" & vbCrLf & "<p>"
      I = 0
      END IF

      ts.Open "select * from bibletable where [bibletable.book title]='" &
      bookopt & "' and [bibletable.chap ter]=" & chap1 & " order by verse ASC",
      connStrx, 3, 4
      If Not ts.EOF Then
      While Not ts.EOF
      response.write " <font color=red>" & ts("verse") & "</font> " &
      ts("textdata") & " "
      ts.MoveNext
      Wend
      ts.close
      else
      end if
      ss.MoveNext

      I = I + 1

      Wend


      Ray at work

      "MRK" <sdkngfksdnf> wrote in message
      news:udrfdc3XEH A.3516@TK2MSFTN GP09.phx.gbl...[color=blue]
      >I want to add a <p> after 10 results are given
      > and do this in a loop after every 10 results.
      > Here is my query and my current results code
      >
      > How would I modify this to add a <P> after
      > every 10 results for ts?
      >
      >[/color]

      Comment

      • MRK

        #4
        Re: Separating results

        DOH !!!
        so simple. thanks
        I should apply my VFP experience more in ASP
        I do simple loops like this all the time in VFP



        "Curt_C [MVP]" <software_AT_da rkfalz.com> wrote in message
        news:ucbApf3XEH A.648@TK2MSFTNG P10.phx.gbl...[color=blue]
        > outside the loop put in a variable (XX = 0)
        > At that point in the loop you want the <P> do a:
        > IF XX >= 10 then
        > ..."<P>"....
        > XX = 0
        > ELSE
        > XX = XX + 1
        > END IF
        >
        >
        > --
        > Curt Christianson
        > Owner/Lead Developer, DF-Software
        > Site: http://www.Darkfalz.com
        > Blog: http://blog.Darkfalz.com
        >
        >
        > "MRK" <sdkngfksdnf> wrote in message
        > news:udrfdc3XEH A.3516@TK2MSFTN GP09.phx.gbl...[color=green]
        > > I want to add a <p> after 10 results are given
        > > and do this in a loop after every 10 results.
        > > Here is my query and my current results code
        > >
        > > How would I modify this to add a <P> after
        > > every 10 results for ts?
        > >
        > >
        > >
        > > <%
        > > Response.Buffer = True
        > > Dim connStrx, rs, ss, ts, book1, verse1, chap1, bookopt
        > > connStrx = "Provider=Micro soft.Jet.OLEDB. 4.0; Data Source=" &
        > > Server.MapPath( "\data\kwm\kjv. mdb")
        > > Set rs = CreateObject("A DODB.Recordset" )
        > > Set ss = CreateObject("A DODB.Recordset" )
        > > Set ts = CreateObject("A DODB.Recordset" )
        > >
        > > rs.Open "select distinct booktitle, book from bibletable order by book[/color]
        > ASC",[color=green]
        > > connStrx, 3, 4
        > > If Not rs.EOF Then
        > > If Request.Form("S ubmit")="GO" Then
        > > bookopt = request.form("b ook")
        > > else
        > > bookopt=""
        > > end if
        > > While Not rs.EOF
        > > If trim(bookopt) = trim(rs("bookti tle")) then
        > > response.write "<option value='" & rs("booktitle" ) & "' selected>"[/color][/color]
        &[color=blue][color=green]
        > > rs("booktitle" ) & "</option>"
        > > else
        > > response.write "<option value='" & rs("booktitle" ) & "'>" &
        > > rs("booktitle" ) & "</option>"
        > > end if
        > > rs.MoveNext
        > > Wend
        > >
        > > ELSE
        > > END IF
        > > rs.close
        > > set rs = nothing
        > >
        > > If len(bookopt)>1 Then
        > > ss.Open "select distinct chapter from bibletable where
        > > [bibletable.book title]='" & bookopt & "' order by chapter ASC",[/color][/color]
        connStrx,[color=blue]
        > 3,[color=green]
        > > 4
        > > If Not ss.EOF Then
        > > While Not ss.EOF
        > > chap1=ss("chapt er")
        > > response.write ss("chapter")
        > >
        > > ' here is where I want to create a <p> after every 10 results
        > >
        > > ts.Open "select * from bibletable where [bibletable.book title]='" &
        > > bookopt & "' and [bibletable.chap ter]=" & chap1 & " order by verse ASC",
        > > connStrx, 3, 4
        > > If Not ts.EOF Then
        > > While Not ts.EOF
        > > response.write " <font color=red>" & ts("verse") & "</font> " &
        > > ts("textdata") & " "
        > > ts.MoveNext
        > > Wend
        > > ts.close
        > > else
        > > end if
        > > ss.MoveNext
        > > Wend
        > > else
        > > end if
        > > end if
        > > %>
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • MRK

          #5
          Re: Separating results

          Thanks Ray.
          as I told Curt. I do simple loops like
          this in VFP and did not think I could do
          it in ASP..

          I did have to rearrange the loop though
          as I wanted the <p> within the ts results
          10 was also to high and had use 7

          Thanks again for the assist

          <%
          If Not ts.EOF Then
          TX=1
          While Not ts.EOF
          IF TX = 7 THEN
          RESPONSE.WRITE "</p>" & vbCrLf & "<p>"
          TX = 0
          END IF
          response.write " <font color=red>" & ts("verse") & "</font> " &
          ts("textdata") & " "
          ts.MoveNext
          TX = TX + 1
          Wend
          ts.close
          else
          end if
          %>


          "Ray at <%=sLocation% > [MVP]" <myfirstname at lane34 dot com> wrote in
          message news:%23sqP7i3X EHA.3716@TK2MSF TNGP11.phx.gbl. ..[color=blue]
          > The simple way is to put in a counter like so (added code in uppercase):
          >
          >
          >
          > DIM I
          > I = 1
          > RESPONSE.WRITE "<p>"
          > While Not ss.EOF
          > chap1=ss("chapt er")
          > response.write ss("chapter")
          >
          > ' here is where I want to create a <p> after every 10 results
          > IF I = 10 THEN
          > RESPONSE.WRITE "</p>" & vbCrLf & "<p>"
          > I = 0
          > END IF
          >
          > ts.Open "select * from bibletable where [bibletable.book title]='" &
          > bookopt & "' and [bibletable.chap ter]=" & chap1 & " order by verse ASC",
          > connStrx, 3, 4
          > If Not ts.EOF Then
          > While Not ts.EOF
          > response.write " <font color=red>" & ts("verse") & "</font> " &
          > ts("textdata") & " "
          > ts.MoveNext
          > Wend
          > ts.close
          > else
          > end if
          > ss.MoveNext
          >
          > I = I + 1
          >
          > Wend
          >
          >
          > Ray at work
          >
          > "MRK" <sdkngfksdnf> wrote in message
          > news:udrfdc3XEH A.3516@TK2MSFTN GP09.phx.gbl...[color=green]
          > >I want to add a <p> after 10 results are given
          > > and do this in a loop after every 10 results.
          > > Here is my query and my current results code
          > >
          > > How would I modify this to add a <P> after
          > > every 10 results for ts?
          > >
          > >[/color]
          >[/color]


          Comment

          Working...