SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Oct 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with ending loop

    Hi

    I have been asked to modify some classic .asp code to split a single column of products into two columns, unfortunately i'm not really experienced with .asp

    http://dev.decortiles.co.uk/products...cat.asp?id=101

    This i've managed by basically duplicating the code that delivers the table cell, image and copy and adding the following code between:

    <%
    rs.movenext

    %>

    Thus is great, but unfortunately when the number of products in a category is not even the site displays an error message in the second column after the final product.

    Was wondering if someone could point me in the right direction for what to do to make the code i've added check if the products are all listed before moving onto the second column.

    The full code is:

    <%
    iCount = 0
    while not rs.EOF
    if iCount mod 2 = 0 then
    response.Write("<tr valign=top>")
    end if
    %>
    <tr>
    <td width="150" valign="top">
    <% if rs("imagefile") & "" <> "" then %>
    <a href="<%=getItemName(rs, "")%>?id=<%=rs("id")%>"><img src="../uploads/productimages/<%=rs("imagefile")%>" alt="<%=rs("name")%>" width="150" height="150" border="0" /></a>
    <% end if %> </td>
    <td valign="top"><h2><%=rs("name")%></h2>
    <!-- <p><%=rs("pricesummary")%></p>
    <% if 1=0 and rs("specialoffersummary") & "" <> "" then %>
    <p><%=rs("specialoffersummary")%></p>
    <% end if %>
    -->
    </p></a>
    <p><a href="<%=getItemName(rs, "")%>?id=<%=rs("id")%>">details &gt;&gt;</a> </p> </td>


    <%
    rs.movenext

    %>


    <td width="150" valign="top">
    <% if rs("imagefile") & "" <> "" then %>
    <a href="<%=getItemName(rs, "")%>?id=<%=rs("id")%>"><img src="../uploads/productimages/<%=rs("imagefile")%>" alt="<%=rs("name")%>" width="150" height="150" border="0" /></a>
    <% end if %> </td>
    <td valign="top"><h2><%=rs("name")%></h2>
    <!-- <p><%=rs("pricesummary")%></p>
    <% if 1=0 and rs("specialoffersummary") & "" <> "" then %>
    <p><%=rs("specialoffersummary")%></p>
    <% end if %>
    -->
    </p></a>
    <p><a href="<%=getItemName(rs, "")%>?id=<%=rs("id")%>">details &gt;&gt;</a> </p> </td>

    </tr>

    <%
    iCount = iCount + 1
    rs.MoveNext
    wend
    out("</table>")
    else
    response.Redirect("default.asp")
    end if %>

    All help appreciated

    Chris

  2. #2
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you have an if statement which says:

    " if 1=0 and " ....

    1 is never equal to 0

    I would start there.

  3. #3
    SitePoint Member
    Join Date
    Oct 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks webber123456

    I'll take a look


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •