Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: while-loop

  1. #1
    Regular Coder
    Join Date
    Feb 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    while-loop

    why the table just can display the bank 1 record and without the bank 2 record....izzit the problem come from the while-loop???anyone can help me please???

    Code:
    response.write "<table border=1 align=center>"
    
    Response.Write "<TR>" & vbCrLf
    response.write vbCrLf & "<td colspan=3>Bank:1</TD>"
    response.write "</tr>" & vbCrLf & vbCrLf
    
    
    response.write "<tr>"
    response.write "<td width=100 height=47 valign=top>Date<br>(dd-mm-yyyy)</td>"
    response.write "<td width=265 valign=top>Email</td>"
    response.write "<td width=52 align=center>Delete</td>"
    response.write "</tr>"
    
    
    Do While Not objRS.EOF
    if objRS("bankID") = "1" then
    Response.Write "<TR>" & vbCrLf
    response.write vbCrLf & "<td>" & objRS("paymentDate") & "</TD>"
    response.write vbCrLf & "<td>" & objRS("email") & "</td>"
    response.write "<td align=center><input type=checkbox name=delete value=" & CInt(objRS("paymentID")) & ">Yes</td>"
    response.write "</tr>" & vbCrLf & vbCrLf
    
    end if
    objRS.MoveNext
    loop
    
    response.write "</table>"
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    response.write "<table border=1 align=center>"
    
    Response.Write "<TR>" & vbCrLf
    response.write vbCrLf & "<td colspan=3>Bank:2</TD>"
    response.write "</tr>" & vbCrLf & vbCrLf
    
    
    response.write "<tr>"
    response.write "<td width=100 height=47 valign=top>Date<br>(dd-mm-yyyy)</td>"
    response.write "<td width=265 valign=top>Email</td>"
    response.write "<td width=52 align=center>Delete</td>"
    response.write "</tr>"
    
    
    Do While Not objRS.EOF
    if objRS("bankID") = "2" then
    Response.Write "<TR>" & vbCrLf
    response.write vbCrLf & "<td>" & objRS("paymentDate") & "</TD>"
    response.write vbCrLf & "<td>" & objRS("email") & "</td>"
    response.write "<td align=center><input type=checkbox name=delete value=" & CInt(objRS("paymentID")) & ">Yes</td>"
    response.write "</tr>" & vbCrLf & vbCrLf
    
    end if
    objRS.MoveNext
    loop
    
    response.write "</table>"
    thanks in advance

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if objRS("bankID") = "1" then
    You've assigned a condition.
    It will only loop if that is met.

  • #3
    Registered User
    Join Date
    Jan 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually...I believe it's because you are at the end of your recordset.

    Before your 2nd loop for Bank ID 2 starts try putting in

    objRS.MoveFirst so it would be




    objRS.MoveFirst
    Do While Not objRS.EOF
    if objRS("bankID") = "2" then
    Response.Write "<TR>" & vbCrLf
    response.write vbCrLf & "<td>" & objRS("paymentDate") & "</TD>"
    response.write vbCrLf & "<td>" & objRS("email") & "</td>"
    response.write "<td align=center><input type=checkbox name=delete value=" & CInt(objRS("paymentID")) & ">Yes</td>"
    response.write "</tr>" & vbCrLf & vbCrLf

    end if
    objRS.MoveNext
    loop

  • #4
    Regular Coder
    Join Date
    Feb 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts
    okok.....i knew dee....thank you very much

  • #5
    Registered User
    Join Date
    Jan 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Happy to help


  •  

    Posting Permissions

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