Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 ASP Looping Help Needed Please
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Lycaster
New Member

USA
60 Posts

Posted - 20 August 2001 :  10:23:54  Show Profile  Visit Lycaster's Homepage  Send Lycaster an AOL message

Fellow ASP Programmers,

I have a question that I know someone in here can help me with.

I am trying to loop through a recordset horizontally. What I mean is; I have a list of products in a table. Right now I have them looping 20 at a time vertically one after another.

I need to be able to have these products loop 3 columns wide and then however many rows doesn’t matter.

So I will get something like this:

Product 1 Product 2 Product 3

Instead of:

Product 1
Product 2
Product 3

Here is the code I am using now:


' Build Content String
If Not oProducts.EOF Then
Do Until oProducts.EOF OR iCounter = 20
' Math function for percentage values
sPercentValue = 1 - (CDBL(oProducts("Current Price").Value)/CDBL(oProducts("Old Price").Value))
sPercentValue = sPercentValue
If oProducts("Priority") = "2" Then
' Build out content string for normal items
strBuild = "<TABLE width=""200"" border=""0"" cellspacing=""0"" cellpadding=""5"">"
strBuild = strBuild & "<TR><TD><P>"
strBuild = strBuild & "<IMG src=" & oProducts("Thumbnail Image").Value & " border=""1""><BR clear=""all""><FONT face=""Verdana, Arial, Helvetica, sans-serif"" size=""1""><A href=""#"">" & oProducts("Item Name").Value & "</A>"
strBuild = strBuild & "<BR clear=""all""><S>" & FormatCurrency((oProducts("Old Price").Value), 2, -2, -2, -2) & "</S> | " & FormatCurrency((oProducts("Current Price").Value), 2, -2, -2, -2) & "<BR clear=""all"">you save " & FormatPercent((sPercentValue), 0, -2, -2, -2) & "</FONT>"
strBuild = strBuild & "</P></TD></TR>"
strBuild = strBuild & "</TABLE>"
sDisplay = sDisplay & strBuild
ElseIf oProducts("Priority") = "1" Then
' Build out content string for featured items
strBuild = "<TABLE width=""200"" border=""0"" cellspacing=""0"" cellpadding=""5"">"
strBuild = strBuild & "<TR><TD><P>"
strBuild = strBuild & "<IMG src=" & oProducts("Thumbnail Image").Value & " border=""1""><BR clear=""all""><FONT face=""Verdana, Arial, Helvetica, sans-serif"" size=""1""><A href=""#"">" & oProducts("Item Name").Value & "</A>"
strBuild = strBuild & "<BR clear=""all""><S>" & FormatCurrency((oProducts("Old Price").Value), 2, -2, -2, -2) & "</S> | " & FormatCurrency((oProducts("Current Price").Value), 2, -2, -2, -2) & "<BR clear=""all"">you save " & FormatPercent((sPercentValue), 0, -2, -2, -2) & "</FONT>"
strBuild = strBuild & "</P></TD></TR>"
strBuild = strBuild & "</TABLE>"
sFeatured = sFeatured & strBuild
End If
oProducts.MoveNext
Loop
End If


If anyone can help I would appreciate it greatly.

Thanks,

Jared
 


Kat
Advanced Member

United Kingdom
3065 Posts

Posted - 20 August 2001 :  10:42:16  Show Profile  Visit Kat's Homepage
Jared,

I am trying to understand exactly what it is you need.
You say you need to have three columns wide, and several rows deep.
How are you deciding when to break off for a new row -
do your products have an id or something that can help you decide which column they go in?

Your code at the moment is creating a brand new table for each product
because you aren't looping around < tr > or < td > elements.

Please try to explain a bit more because although I understand what you need,
I don't understand your data enough to give you the code verbatum.

It looks to me like you need to use your database call to sort your products first into the correct order and then you can loop through them more easily.

Please try and provide more information - I will then do my best to help if I can.

Kat.

KatsKorner


Edited by - kat on 20 August 2001 10:43:56
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.34 seconds. Powered By: Snitz Forums 2000 Version 3.4.07