---
title: "Bryta rad"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/74666-bryta-rad"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "Asa"
published: "2003-04-22T08:17:31.000Z"
updated: "2003-04-24T10:29:08.000Z"
replies: 3
views: 184
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/74666-bryta-rad"
---

# Bryta rad

## #1 — Asa, 2003-04-22T08:17Z

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%>
```

Permalänk: https://www.webforum.nu/p/74666

## #2 — OveRRidE, 2003-04-22T08:29Z

```
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
```

Permalänk: https://www.webforum.nu/p/1019034

## #3 — Asa, 2003-04-22T09:43Z

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%>
```

Permalänk: https://www.webforum.nu/p/1019062

## #4 — Asa, 2003-04-24T10:29Z

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?

Permalänk: https://www.webforum.nu/p/1023650

---

Tråden på webben: https://www.webforum.nu/amne/asp/74666-bryta-rad
