Results 1 to 1 of 1

Thread: Loop Problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2004
    Posts
    100

    Loop Problem

    I am having problem with my loop.
    Referring to the table.jpg, the row repeats with the same data for column Nama and ID.
    Do you have any idea how can I group the data so that there wont be any repeatition.
    Thanks in advance.

    Below is the portion of my code.
    VB Code:
    1. set gStaf = server.CreateObject("adodb.recordset")
    2.                 gStaf.open "SELECT * FROM staf " ,conn
    3.                
    4.                 k=0
    5.                 for i=1 to gstaf.recordcount
    6.                
    7.                    
    8.                     set gPermohonan = server.CreateObject("adodb.recordset")
    9.                     gPermohonan.open "SELECT * FROM permohonan WHERE jpk=2 AND uid="&gStaf("id")&" " ,conn
    10.                    
    11.                    
    12.                     if not gStaf.eof then
    13.                                                
    14.                         for j=1 to gPermohonan.recordcount
    15.                         k=k+1
    16.             %>
    17.                         <tr class="bgcontent">
    18.                         <td><%=k%></td>
    19.                         <td><%=gStaf("bno")%></td>
    20.                         <td><%=gStaf("nama")%></td>
    21.                         <td>
    22.                             <%
    23.                                 set mc = server.CreateObject("adodb.recordset")
    24.                                 mc.open "SELECT * FROM permohonan WHERE jpk=2 AND uid="&gStaf("id")&" AND tarikhmula >= #"&request.Form("tarikhmula")&"# AND tarikhmula <= #"&request.form("tarikhtamat")&"# ",conn
    25.                                
    26.                                 if not mc.eof then
    27.                                     for x=1 to mc.recordcount
    28.                                         tarikhM = mc("tarikhmula")
    29.                                         tarikhT = mc("tarikhtamat")
    30.                                         uid = mc("uid")
    31.                                        
    32.                                     'untuk first record
    33.                                     if x=1 then
    34.                                         response.Write(tarikhM &" - "& tarikhT)
    35.                                         response.Write("<br>")
    36.                                     end if
    37.                                    
    38.                                     'untuk record yg seterusnya..pegi kat previous record
    39.                                     'sbb nak amek nilai uid masuk kat variable userID..rationally tgk kat if kat bawah
    40.                                     if x>=2 then
    41.                                         mc.moveprevious
    42.                                         userID = mc("uid")
    43.                                         mc.movenext
    44.                                    
    45.                                     'pas tuh compare userID yg previous record ngn uid current record
    46.                                     'kalo tak sama baru break
    47.                                     if uid = userID then
    48.                                         response.write(tarikhM &"-"& tarikhT)  
    49.                                         response.Write("<br>")                             
    50.                                     end if
    51.                                    
    52.                                    
    53.                                 end if
    54.                                 'end if
    55.                             %>
    56.                            
    57.                             <%
    58.                                 mc.movenext
    59.                                 next
    60.                                 end if
    61.                             %>
    62.                         </td>
    63.                         <td>&nbsp;</td>
    64.                         <td>&nbsp;</td>
    65.                         <td>&nbsp;</td>
    66.                         </tr>
    67.                        
    68.                 <%
    69.                     gPermohonan.movenext
    70.                     next
    71.                     end if
    72.                     gStaf.movenext
    73.                     next
    74.                 %>
    Attached Images Attached Images  

Posting Permissions

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



Click Here to Expand Forum to Full Width