By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,435 Members | 2,939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,435 IT Pros & Developers. It's quick & easy.

ASP - how to select values from different fields and loop through them?

P: 10
I have a table with many different fields in, including 40 separate image fields. ("Pic1" "Pic2" "Pic3" etc...)
each field has a single value (an image name) in, I need to be able to select all these fields as a single record and loop through them.

Something like
Expand|Select|Wrap|Line Numbers
  1. Select Pic1, Pic2, Pic3, Pic4, etc... From Gallery Where GalleryID = 123
Each gallery has a unique id in the table and has several different fields including a couple of text fields, and 40 different image fields.

Not every gallery will have 40 actual images in, so im looking to select all the image fields that actually have data for that gallery, and then to be able to count the number of images and loop through displaying them on the page.

Im not very good at programming, just a tiny little bit of self taught basic asp. So any help would be really appreciated.
Apr 17 '13 #1
Share this Question
Share on Google+
3 Replies

P: 10
Im not sure I explained myself very clearly above.

After selecting the fields that I require from the table,
I want to be able to group them somehow as if they were all selected from a single field, and then count them, and loop through displaying them on the page one after the other.

I know how to select the fields I need, but it is the grouping, counting and looping through part I need guidance with.

Is that better explained?
Apr 17 '13 #2

P: 10
I dont know if I should be using Array?
I could select all the fields I need then do something like:

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Select Pic1, Pic2, Pic3, Pic4, Pic5, Pic6, Pic7, Pic8, Pic9, Pic10 From Gallery Where GalleryID = 123
  3. %>
  6. <%
  7. Dim GalleryArray() 'Dynamic array
  8. GalleryArray(0) = "rsGallery.Item("Pic1").value"
  9. GalleryArray(1) = "rsGallery.Item("Pic2").value"
  10. GalleryArray(2) = "rsGallery.Item("Pic3").value"
  11. GalleryArray(3) = "rsGallery.Item("Pic4").value"
  12. GalleryArray(4) = "rsGallery.Item("Pic5").value"
  13. GalleryArray(5) = "rsGallery.Item("Pic6").value"
  14. GalleryArray(6) = "rsGallery.Item("Pic7").value"
  15. GalleryArray(7) = "rsGallery.Item("Pic8").value""
  16. GalleryArray(8) = "rsGallery.Item("Pic9").value"
  17. GalleryArray(9) = "rsGallery.Item("Pic10").value"
  18. For Each item In GalleryArray
  19.     Response.Write(item & "<br />")
  20. Next
  21. %>
But that wouldnt count the number of images and I dont even know if it would display each image separately and allow me to control the layout?
Apr 17 '13 #3

Expert Mod 10K+
P: 12,366
Is this the same question as your other thread?
Apr 17 '13 #4

Post your reply

Sign in to post your reply or Sign up for a free account.