OK you clever peple out there!!!

Can you solve this one for me?

I need to edit this code so it will dynamically loop a series of images based
on the number of columns held in a database field.

My current code looks like this:
<%
startrw = 0
endrw = HLooper1__index
numberColumns = 3
numrows = -1
while((numrows <> 0) AND (Not greetingcards.EOF))
startrw = endrw + 1
endrw = endrw + numberColumns
%>

but i need to code it so that numberColumns = 3

is dynamically controlled by my database so the count can vary depending upon
the records selected

I essentially want it to replace the 3 with the number in my database but the
edited code below (hightlighted) does not work.

<%
startrw = 0
endrw = HLooper1__index
numberColumns = <%=(looperrepeat.Fields.Item("repeatcount").Value) %>
numrows = -1
while((numrows <> 0) AND (Not greetingcards.EOF))
startrw = endrw + 1
endrw = endrw + numberColumns
%>

If anyone has any ideas on this it would be much appreciated!!!

Many thanks all
Steve