<% option explicit Response.Buffer = True dim ColumnArray(), DataArray() dim intColumns, sql, i, j, k, txtContinue dim rs, Conn 'Get Database Connection Script %> <!--#INCLUDE Virtual="/ratios/_scripts/db/open-now-conn.asp"--> <!--#INCLUDE Virtual="adovbs.inc"--> <% intColumns = 2 sql = "SELECT txtSiteName, txtLink, txtDescription " sql = sql & "FROM tblASPSites " sql = sql & "ORDER BY txtSiteName" set rs = server.CreateObject("ADODB.Recordset") rs.Open sql, Conn, adOpenStatic redim ColumnArray(intColumns-1) for i = 0 to ubound(ColumnArray) ColumnArray(i) = rs.RecordCount * (i+1)/(intColumns) next 'dimensionalize the array to hold 3 pieces of additional info redim DataArray(rs.RecordCount/(intColumns-1),intColumns,3) for i = 0 to intColumns - 1 k = 0 do while j < ColumnArray(i) DataArray(k,i,0) = rs("txtSiteName") DataArray(k,i,1) = rs("txtLink") 'txtLink is the url of the Site DataArray(k,i,2) = j + 1 'records the record # DataArray(k,i,3) = rs("txtDescription") 'txtDescription is a description of the Site j = j + 1 k = k + 1 rs.MoveNext loop next rs.Close set rs = Nothing conn.Close set conn = Nothing %> <table border=1 align=center> <%'Write a header column %> <tr><td colspan=<%=intColumns*2%> align=center><b>Popular ASP Sites</b><br>(ordered alphabetically)</td></tr> <% for i = 0 to ubound(DataArray) Response.Write("<tr>") for j = 0 to intColumns - 1 Response.Write("<td>") if DataArray(i,j,0) <> "" then 'Write the number, site name, and hyperlink in the first cell Response.Write(DataArray(i,j,2) & ". " & "<a href=" & DataArray(i,j,1) & ">" & DataArray(i,j,0) & "</a>") else Response.Write("&nbsp;") end if Response.Write("</td>") Response.Write("<td>") if DataArray(i,j,0) <> "" then 'Write the description of the site in the second cell Response.Write(DataArray(i,j,3)) else Response.Write("&nbsp;") end if Response.Write("</td>") next Response.Write("</tr>") txtContinue = "" for j = 0 to intColumns - 1 txtContinue = txtContinue & DataArray(i+1,j,0) next if txtContinue = "" then Exit For end if next %> </table>