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:
set gStaf = server.CreateObject("adodb.recordset")
gStaf.open "SELECT * FROM staf " ,conn
k=0
for i=1 to gstaf.recordcount
set gPermohonan = server.CreateObject("adodb.recordset")
gPermohonan.open "SELECT * FROM permohonan WHERE jpk=2 AND uid="&gStaf("id")&" " ,conn
if not gStaf.eof then
for j=1 to gPermohonan.recordcount
k=k+1
%>
<tr class="bgcontent">
<td><%=k%></td>
<td><%=gStaf("bno")%></td>
<td><%=gStaf("nama")%></td>
<td>
<%
set mc = server.CreateObject("adodb.recordset")
mc.open "SELECT * FROM permohonan WHERE jpk=2 AND uid="&gStaf("id")&" AND tarikhmula >= #"&request.Form("tarikhmula")&"# AND tarikhmula <= #"&request.form("tarikhtamat")&"# ",conn
if not mc.eof then
for x=1 to mc.recordcount
tarikhM = mc("tarikhmula")
tarikhT = mc("tarikhtamat")
uid = mc("uid")
'untuk first record
if x=1 then
response.Write(tarikhM &" - "& tarikhT)
response.Write("<br>")
end if
'untuk record yg seterusnya..pegi kat previous record
'sbb nak amek nilai uid masuk kat variable userID..rationally tgk kat if kat bawah
if x>=2 then
mc.moveprevious
userID = mc("uid")
mc.movenext
'pas tuh compare userID yg previous record ngn uid current record
'kalo tak sama baru break
if uid = userID then
response.write(tarikhM &"-"& tarikhT)
response.Write("<br>")
end if
end if
'end if
%>
<%
mc.movenext
next
end if
%>
</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<%
gPermohonan.movenext
next
end if
gStaf.movenext
next
%>