%
Const MaxNumberofCols = 4
Const PictureWidth = 100
Const PictureHeight = 100
%><%
PageHeader "Products", "products"
%>
<%
Function DivideRoundUp(num1,num2)
if num1 mod num2 = 0 then
divideroundup = num1 / num2
else
divideroundup = int(num1 / num2) + 1
end if
end function
dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Source = "SELECT ID, Name, OrderNum FROM Catagories Order By OrderNum"
rs.ActiveConnection = "DBQ=" & Server.MapPath("products.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};DriverId=25"
rs.CursorType = adOpenStatic
rs.Open
dim rsCount
rsCount = 0
do until rs.EOF
rsCount = rsCount + 1
rs.MoveNext
loop
rs.MoveFirst
dim rows, cols, pos
rows = divideroundup(rsCount,MaxNumberofCols)
cols = divideroundup(rsCount,rows)
pos = 0
do until rs.EOF
if pos = 0 then
%>
<%
end if
%>
"> " width="<%=PictureWidth%>" height="<%=PictureHeight%>" border="0">
<%=rs.fields("name")%> |
<%
pos = (pos + 1) mod cols
if pos = 0 then
%>
<%
end if
rs.MoveNext
loop
rs.Close
if pos = 1 then
%><%
end if
%>
<%
PageFooter
%>