Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
04-11-2007, 07:09 PM #1
- Join Date
- Dec 2002
- NW Iowa
- Thanked 0 Times in 0 Posts
Get all records, loop through them, repeat infinitely
OK, forgive me if I'm not using the correct language, but I have an ad-display system where I need to get all the current records in the recordset and loop through them in some sort of an array. When the last record is reached, I need to go back to the first record.
For example, say there are 3 records:
f_Name BMW Z4
f_Name BMW Motorcycle
f_Name BMW 5-Series
Here is my current code, (http://portal.labellasera.com/screensaver.htm) which I have somewhat commented (in green). My current problem is, if there are records missing in between, (1, 2, 3, 5, 6, 7), then it will still get that image, even though it doesn't exist. So somehow, hopefully with your extreme help (I haven't even gotten a slight clue), I can get this thing working.
Overall, what I need to acheive is to get the first good record, then redirect to the next for 'x' seconds, then redirect to the next for 'x' seconds, then redirect to the last record for 'x' seconds, then go back to the first record. Any help you can give is greatly appreciated.
Thanks in advance,
Last edited by mattboy_slim; 04-11-2007 at 07:36 PM. Reason: Change Title, better to understand
04-11-2007, 08:59 PM #2
- Join Date
- Mar 2007
- Thanked 19 Times in 19 Posts
What it sounds like you want a spinner function, doing a specific thing until a certain point and then restart.
Numeric and Date spinners are usually found with up/down arrows and dates/times/numbers, but can be used for anything (Look at the JS forum and look for my post (and GlennGV's) post on number spinners).
As to what you need to do to fix this -- I don't know yet. Your code, written with Dreamweaver, is a little confusing. You are constantly jumping in and out of ASP, and using <%= and response.write together in the same statement (<%= is the same as response.write).
The easiest way to do this would be to use the FirstRecord variable as a starting point.
<% Dim PreviousPage Dim NextPage Dim FirstRecord PreviousPage = request.QueryString("ID") NextPage = PreviousPage +1 FirstRecord = (rs_screensaverall.Fields.Item("f_ID").Value) %>
<% If request.QueryString <> "" then If Not rs_screensaver.EOF Or Not rs_screensaver.BOF Then response.write("<div class=""wraptocenter""><img alt=""" & rs_screensaver.Fields.Item("f_Name").Value & """ src=""_ads/" & rs_screensaver.Fields.Item("f_File").Value & """ /></div>") Else response.redirect("screensaver.asp?ID=" & FirstRecord) End If End If %>
If the code hits the EOF or BOF, then it does the same as hitting the Default Page link.
NOTE: I usually have the ability to test all my work before sending it out here, but I can't in this case. Please let me know if you have any issues with the code and we can work them out.