Mhtml
10-19-2002, 09:44 AM
I'm trying to count the number of records from a database table when in the middle of a loop.
I'm trying to make a mini message board but I'm stuck on getting the number of replies.
The replies are in a separate table and I need to insert them into the loop, they can be identified for which thread they belong to by the column ToThreadId and in the threads table there is the ThreadId column to make it all work out.
I can display replies but counting them and putting them next to the apropriate thread link is harder.
Try working it out from this code I have tried to use:[code]
SqlGT = "SELECT * FROM Threads"
rs.open SqlGT,Qconn
SqlGC = "SELECT COUNT(*) AS RpC FROM Replies WHERE ToThreadId="&rs("ThreadId")
rs.open SqlGC,Qconn
Do While not rs.EOF
Response.Write("<tr>")
Response.Write("<td width=1 height=20> </td>")
Response.Write("<td width=362 align=center valign=middle bgcolor=e5e5e5><font size=2 face=Arial, Helvetica, sans-serif>"&rs("ThreadSubject")&"</font></td>")
Response.Write("<td width=165 align=center valign=middle bgcolor=cccccc><font size=2 face=Arial, Helvetica, sans-serif>"&rs("ThreadStarter"))
Response.Write("</font></td>")
Response.Write("<td width=165 align=center valign=middle bgcolor=cccccc><font size=2 face=Arial, Helvetica, sans-serif>"&rs("RpC"))
Response.Write("</font></td>")
Response.Write("</tr>")
rs.MoveNext
loop%>
I'm trying to make a mini message board but I'm stuck on getting the number of replies.
The replies are in a separate table and I need to insert them into the loop, they can be identified for which thread they belong to by the column ToThreadId and in the threads table there is the ThreadId column to make it all work out.
I can display replies but counting them and putting them next to the apropriate thread link is harder.
Try working it out from this code I have tried to use:[code]
SqlGT = "SELECT * FROM Threads"
rs.open SqlGT,Qconn
SqlGC = "SELECT COUNT(*) AS RpC FROM Replies WHERE ToThreadId="&rs("ThreadId")
rs.open SqlGC,Qconn
Do While not rs.EOF
Response.Write("<tr>")
Response.Write("<td width=1 height=20> </td>")
Response.Write("<td width=362 align=center valign=middle bgcolor=e5e5e5><font size=2 face=Arial, Helvetica, sans-serif>"&rs("ThreadSubject")&"</font></td>")
Response.Write("<td width=165 align=center valign=middle bgcolor=cccccc><font size=2 face=Arial, Helvetica, sans-serif>"&rs("ThreadStarter"))
Response.Write("</font></td>")
Response.Write("<td width=165 align=center valign=middle bgcolor=cccccc><font size=2 face=Arial, Helvetica, sans-serif>"&rs("RpC"))
Response.Write("</font></td>")
Response.Write("</tr>")
rs.MoveNext
loop%>