View Single Post
  #2  
Old 07-17-2009, 10:55 PM
melinite melinite is offline
Member
 
Join Date: Nov 2008
Posts: 12
Add <tr> tags before and </tr> after loop
I usually also had thead and tbody to any html tables.
added markup is highlighted in blue.

pseudocode:

count currentrow modulo 4 = 0, then

</tr><tr>

Continue


------------------------------
<%
int RecordCounter = 0; //initialize currentrow counter
int numcolumns = 4; //columns you want
%>


<table border="0">
<tr>

<%

if(rs.next()) {
rs.beforeFirst(); // for making sure you dont miss the first record.
while(rs.next())
{ // opening while loop brackets.

%>



<td>
<div style=""><img border="3"
src="images/Beanie/<%=rs.getString("ProdImage") %>" height="145" width="145" /></div>


<a href="ProductDesc.jsp?ProductId=<%=rs.getString("P roductId")%>"><%=rs.getString("ProdName")%></a>
</td>

<% RecordCounter++; // iterate record
if (RecordCounter % numcolumns == 0)
out.print("</tr> <tr>"); //close and start new row after 4th <TD>
%>



<%
} //closing while loop bracket
}
else {
//if no record is found, simply display a no record message
%>
Nothing.
<%
}
%>

</tr>
</table>
Reply With Quote