Problem with asp loop........

Discussion in 'ASP General' started by David, Feb 15, 2006.

  1. David

    David Guest

    Hi,

    The data I am trying to print on the web looks as follows:

    Date 1

    Record 1
    Record 2
    Record 3

    Date 2

    Record 1
    Record 2
    Record 3

    and onwards ..........................

    This I have working fine.
    I need to add a calculation into the page print, so the page looks
    like:

    Date 1 (There are 437 units this week)

    Record 1
    Record 2
    Record 3

    Date 2 (There are 821 units this week)

    Record 1
    Record 2
    Record 3

    PROBLEM:
    The calculation is done by stuffing a variable at the end of the loop,
    and then calling a function which prints either 'No Data' or 'There are
    xxx units this week'

    Because the calculation has to be done at the end of the record loop
    before the date changes, when the page first loads, the first date
    header always reads:

    Date 1 (No Data)

    Record 1
    Record 2
    Record 3

    Which is true, because the code has not yet looped through that dates
    records, and hence the calculation = 0. Except there is a value. How
    can I get around this problem ??

    The calculation for the 1st date in the recordset is always printed
    against the 2nd date header and so on down the listing. This is
    obvious, as on the second loop, the first calculation has been done,
    and gets printed when the next date header is created.... :-(

    Much confused. I have tried everything I know.

    Thanks in advance

    David
     
    David, Feb 15, 2006
    #1
    1. Advertising

  2. David

    Evertjan. Guest

    David wrote on 15 feb 2006 in microsoft.public.inetserver.asp.general:

    > Because the calculation has to be done at the end of the record loop
    > before the date changes, when the page first loads, the first date
    > header always reads:
    >
    > Date 1 (No Data)
    >
    > Record 1
    > Record 2
    > Record 3
    >


    Safe your html code in a string and response.write that later:


    s1 = "<br><br>Date 1"

    '' start of loop

    s3 = "<br><br>Record 1"

    s3 = s3 & "<br>Record 2"

    s3 = s3 & "<br>Record 3"

    '' end of loop

    s2 = "(computed result)"

    response.write s1 & s2 & s3

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Feb 15, 2006
    #2
    1. Advertising

  3. David

    Noozer Guest

    >
    > PROBLEM:
    > The calculation is done by stuffing a variable at the end of the loop,
    > and then calling a function which prints either 'No Data' or 'There are
    > xxx units this week'


    Loop twice?

    Build your output and output it at the end of the loop?

    Where is the data coming from?
     
    Noozer, Feb 15, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VGltOjouLg==?=

    Loop the loop...

    =?Utf-8?B?VGltOjouLg==?=, Feb 16, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,418
    Karl Seguin
    Feb 16, 2005
  2. Steven

    while loop in a while loop

    Steven, Mar 24, 2005, in forum: Java
    Replies:
    5
    Views:
    2,294
    Tim Slattery
    Mar 30, 2005
  3. -
    Replies:
    12
    Views:
    718
    Remon van Vliet
    Jun 15, 2005
  4. Byte
    Replies:
    4
    Views:
    438
  5. Isaac Won
    Replies:
    9
    Views:
    458
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page