Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

build table from array 3

Status
Not open for further replies.

yahve

Programmer
Nov 14, 2000
159
CA
Hi,

This one is giving me a headache. I'm building a products page from an Access2000 db. The idea is to have the same page displaying one chosen product at the time. One of the fields in the db contains a list of images URLs relating to the product, separated by a delimiter. Not all the products have the same number of images. I'm spliting that field in the asp page and building a table from that array.

The question is: how can I make my table 2 columns wide whatever the number of images the array contains? I need someway to build the first row with the first two elements of the array, then build a second row, and so on.

Is there a better way, using divs maybe, to format my page into two columns? Should I keep my images URL in a separated table and use data shaping instead of the array thing I'm now doing?

Any suggestion would be appreciated.

Thanks.

 
<%@ Language=VBScript %>
<%
Dim YourArray(5)

YourArray(1) = &quot;TEST&quot;
YourArray(2) = &quot;TAST&quot;
YourArray(3) = &quot;TUST&quot;
YourArray(4) = &quot;TOST&quot;
YourArray(5) = &quot;TIST&quot;

Response.Write &quot;<table>&quot;

for i = 1 to ubound( YourArray )
if i/2 <> Cint(i/2) then response.write &quot;<tr>&quot;
response.write &quot;<td>&quot; & YourArray(i) & &quot;</td>&quot;
if i/2 = Cint(i/2) then response.write &quot;</tr>&quot;
next

Response.Write &quot;</table>&quot;

%> br
Gerard
 
Hi Gerard,

Thanks for the tip, I was thinking of something like that but was not sure how to go about it. I'll try it out.

Bye.
 
Hi Gerard,

Here's what I finally did, it works great:

Code:
response.write(&quot;<table><tr>&quot;)
if (Ubound(a)/2) = CInt((Ubound(a)/2)) then
    for i = 0 to (UBound(a)-1)
    if i/2 = Cint(i/2) then
        response.write(&quot;<td>&quot; & a(i))
    else
        response.write(&quot;<td>&quot; & a(i) & &quot;</td></tr>&quot;)
    end if
    next
else
    for i = 0 to (UBound(a)-1)
    if i/2 = Cint(i/2) then
        response.write(&quot;<td>&quot; & a(i))
    else
        response.write(&quot;<td>&quot; & a(i) & &quot;</td></tr>&quot;)
    end if
    next
    response.write(&quot;<td></td></tr>&quot;)
end if
response.write(&quot;</table>&quot;)

Thanks again for showing me the way!

Bye.
 
I'm glad my reply was helpfull for you.
But why are the stars on *your* replies?
In fact: why are there stars on the original question ??? br
Gerard
 
Hi,

Like any VERY goog consultant, I get paid for asking question, not for answering them... ;-) don't you agree?

Thanks again

Bye.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top