AsaMedlem sedan dec. 20011 860 inlägg Någon som vet hur jag ska göra för att denna kod efter ex 2 ska byta rad?? Detta ska enkelt vara valbart upptill.
<%maxnumber = 3
Set RS = Conn.execute("SELECT id,product,cat,picture,price FROM shop_products Where picture <> ''")
response.write "<table width=""100%"" border=""0"" align=""center""><tr>"
if not rs.eof then
arr = rs.getrows()
items = ubound(arr,2) + 1
if items < maxNumber then maxNumber = items
dim choosen()
redim choosen(maxnumber-1)
randomize
cnt = 0
Do Until cnt = maxnumber
RndNumber = Int(Rnd * items)
found = false
for i = 0 to cnt - 1
if choosen(i) = rndNumber then
found = true
exit for
end if
next
if not found then
choosen(cnt) = rndNumber
cnt = cnt + 1
Set cat=Conn.Execute("Select * From shop_category Where id=" & arr(2,rndNumber))%>
<td width="33%" valign="top" <%If cnt < 3 Then%> style="border-right: 1px solid <%=ShopInst("color1")%>"<%End If%>>
<table width="33%" border="0">
<tr>
<td valign="top" width="60%"><a href="viewProduct.asp?cat=<%=cat("ucategory")%>&ucat=<%=arr(2,rndNumber)%>&ID=<%=arr(0,rndNumber)%>"><%=arr(1,rndNumber)%></a></td>
<td valign="top" width="40%"><a href="viewProduct.asp?cat=<%=cat("ucategory")%>&ucat=<%=arr(2,rndNumber)%>&ID=<%=arr(0,rndNumber)%>"><img src="products/<%=arr(3,rndNumber)%>" border="1" width="70" height="70" alt="Klicka för större bild"></a></td>
</tr>
<tr>
<td valign="top" width="60%"><br><font color="red" size="2"><b><%=FormatNumber(arr(4,rndNumber),0)%>:-</b></font></td>
<td valign="top" align="right" width="40%"><br><a href="javascript:add('buy.asp?cat=<%=cat("ucategory")%>&ucat=<%=arr(2,rndNumber)%>&ID=<%=arr(0,rndNumber)%>&type=start','bottom.asp');"><img src="bilder/kop.gif" border="0"></a></td>
</tr>
</table>
</td>
<%end if
loop
else
response.write "<td></td>"
end if
response.write "</tr></table>"
RS.Close
Set Rs = Nothing%>
OveRRidEMedlem sedan feb. 200112 078 inlägg Do Until cnt = maxnumber
yxa = yxa + 1
RndNumber = Int(Rnd * items)
found = false
for i = 0 to cnt - 1
if choosen(i) = rndNumber then
found = true
exit for
end if
next
if not found then
choosen(cnt) = rndNumber
cnt = cnt + 1
Set cat=Conn.Execute("Select * From shop_category Where id=" & arr(2,rndNumber))%>
<td width="33%" valign="top" <%If cnt < 3 Then%> style="border-right: 1px solid <%=ShopInst("color1")%>"<%End If%>>
<table width="33%" border="0">
<tr>
<td valign="top" width="60%"><a href="viewProduct.asp?cat=<%=cat("ucategory")%>&ucat=<%=arr(2,rndNumber)%>&ID=<%=arr(0,rndNumber)%>"><%=arr(1,rndNumber)%></a></td>
<td valign="top" width="40%"><a href="viewProduct.asp?cat=<%=cat("ucategory")%>&ucat=<%=arr(2,rndNumber)%>&ID=<%=arr(0,rndNumber)%>"><img src="products/<%=arr(3,rndNumber)%>" border="1" width="70" height="70" alt="Klicka för större bild"></a></td>
</tr>
<tr>
<td valign="top" width="60%"><br><font color="red" size="2"><b><%=FormatNumber(arr(4,rndNumber),0)%>:-</b></font></td>
<td valign="top" align="right" width="40%"><br><a href="java script:add('buy.asp?cat=<%=cat("ucategory")%>&ucat=<%=arr(2,rndNumber)%>&ID=<%=arr(0,rndNumber)%>&type=start','bottom.asp');"><img src="bilder/kop.gif" border="0"></a></td>
</tr>
</table>
</td>
<%
if yxa = maxnumber then
yxa = 0 %>
</tr><tr>
<% end if
end if
loop
AsaMedlem sedan dec. 20011 860 inlägg Jag ändrade det du ändrat till såhär. Nu funkar det att i mitt fall visa 4 bilder totalt med 2 per rad men ibland visas alla på en rad. Nån ide varför?
<%
maxnumber = 4
PerRad = 2
Set RS = Conn.execute("SELECT id,product,cat,picture,price FROM shop_products Where picture <> ''")
response.write "<table width=""100%"" border=""0"" align=""center""><tr>"
if not rs.eof then
arr = rs.getrows()
items = ubound(arr,2) + 1
if items < maxNumber then maxNumber = items
dim choosen()
redim choosen(maxnumber-1)
randomize
cnt = 0
yxa = 0
Do Until cnt = maxnumber
yxa = yxa + 1
RndNumber = Int(Rnd * items)
found = false
for i = 0 to cnt - 1
if choosen(i) = rndNumber then
found = true
exit for
end if
next
if not found then
choosen(cnt) = rndNumber
cnt = cnt + 1
Set cat=Conn.Execute("Select * From shop_category Where id=" & arr(2,rndNumber))%>
<td width="50%" valign="top">
<table width="50%" border="0">
<tr>
<td valign="top" width="60%"><a href="viewProduct.asp?cat=<%=cat("ucategory")%>&ucat=<%=arr(2,rndNumber)%>&ID=<%=arr(0,rndNumber)%>"><%=arr(1,rndNumber)%></a></td>
<td valign="top" width="40%"><a href="viewProduct.asp?cat=<%=cat("ucategory")%>&ucat=<%=arr(2,rndNumber)%>&ID=<%=arr(0,rndNumber)%>"><img src="products/<%=arr(3,rndNumber)%>" border="1" width="70" height="70" alt="Klicka för större bild"></a></td>
</tr>
<tr>
<td valign="top" width="60%"><br><font color="red" size="2"><b><%=FormatNumber(arr(4,rndNumber),0)%>:-</b></font></td>
<td valign="top" align="right" width="40%"><br><a href="java script:add('buy.asp?cat=<%=cat("ucategory")%>&ucat=<%=arr(2,rndNumber)%>&ID=<%=arr(0,rndNumber)%>&type=start','bottom.asp');"><img src="bilder/kop.gif" border="0"></a></td>
</tr>
</table>
</td>
<%if yxa = PerRad then
yxa = 0 %>
</tr><tr>
<%end if
end if
loop
else
response.write "<td></td>"
end if
response.write "</tr></table>"
RS.Close
Set Rs = Nothing%>
AsaMedlem sedan dec. 20011 860 inlägg Nu funkar det att i mitt fall visa 4 bilder totalt med 2 per rad men ibland visas alla på en rad eller 3 på en rad å den fjärde på rad 2. Någon som vet vad som strular i koden?