Click to See Complete Forum and Search --> : Display 5 columns per row???


shanuragu
10-28-2003, 11:10 PM
Hi

I am just generating a color pallette, by storing color codes in an array & displaying then in a td with in a for loop. Here is the code ... (for the time being I have taken only six colors)

<%
Dim colorArr, colorName, i, l, j
colorArr = Array("#FFB6C1", "#DB7093", "#D8BFD8", "#DA70D6", "#FFF0F5", "#DDA0DD")
l = UBound(colorArr)
%>
<table width="300px" border="1" cellpadding="0" cellspacing="0">
<tr>
<%
For i = 0 to l
%>
<td bgcolor="<%=colorArr(i)%>"><a href="cssgenerator2.asp?ccode="+<%=colorArr(i)%>><%=colorArr(i)%><a></td>
<%
Next
%>
</tr>
</table>

Which is working fine. I just want to display 5 columns per row using the same for loop. How can I do that???

shara

rdoekes
10-29-2003, 05:53 AM
For i = 0 To l
If i MOD 5 = 0 Then Response.Write "<tr>"
%>
<td bgcolor="<%=colorArr(i)%>">
<a href="cssgenerator2.asp?ccode="+<%=colorArr(i)%>>
<%=colorArr(i)%><a></td>
<%
If i MOD 5 = 4 Then Response.Write "</tr>"
Next
'---now the trailing cells
If l MOD 5 > 4 Then
For i = 0 To 4 - (l Mod 5)
response.Write "<td>&nbsp;</td>"
Next
Response.Write "</tr>"
End If
%>

shanuragu
10-29-2003, 09:59 PM
Thanks rdoekes ... it is working fine

shara

mpempe
01-19-2005, 04:55 PM
hellow
I try to make my script who display photos to display 5 columns per row like the script the "shanuragu"

How i use the script of friend "rdoekes" to work with my script
the code is:


<%
' Get the Current Page
pg = TRIM( Request( "pg" ) )
IF pg = "" THEN pg = 1

' Open the Recordset
Set prodRS = Server.CreateObject( "ADODB.Recordset" )
prodRS.ActiveConnection = Con
prodRS.CursorType = adOpenStatic
prodRS.PageSize = 10
sqlString = "SELECT product_id, product_picture, product_name, product_briefDesc " &_
"FROM Products WHERE product_category='" & cat & "' " &_
"AND product_status=1 " &_
"ORDER BY product_name "
prodRS.Open sqlString
prodRS.AbsolutePage = pg
%>
<table width="56" border=0
cellpadding=5 cellspacing=0>
<%
WHILE NOT prodRS.EOF AND rowCount < prodRS.PageSize
rowCount = rowCount + 1
%>
<tr>
<td width="46">
<IMG SRC="<%=prodRS( "product_picture" )%>"
HSPACE=4 VSPACE=4 BORDER=0 align="center" width="126" height="132">
</td>
</tr>
<tr>
<td align="center" width="46">
&nbsp;
</td>
</tr>
<%
prodRS.MoveNext
WEND
%>
</table>
<%
IF prodRS.PageCount > 1 THEN
%>
<font color="darkgreen">
<b>Go to page: </b>
<%
FOR i = 1 to prodRS.PageCount
IF i <> cINT( pg ) THEN
%>
<a href="main.asp?cat=<%=cat%>&pg=<%=i%>">
<%=i%></a>&nbsp;
<% ELSE %>
<b><%=i%></b>&nbsp;
<% END IF %>
<%
NEXT
%>
</font>
<%
END IF
%>


I try


Thanks for any healp