[thelist] Re: Strange problem with ASP (random) (here is the code)
Chris Anderson
ckanderson at powersurfr.com
Sun Jan 20 02:52:14 CST 2002
Ok, no laughing at my terrible coding... :)
Maybe I should describe whats going on here... remember, I didnt read any
books, I just farted around on my own to get something that worked :)
The SQL21 part is what first goes into the database to see how many lines
there are in there. It just keeps counting (randombookcounter) until it
gets to EOF. From there we have the number of lines in that table.
Then I take a random number with the pick_row88 =
Int(Rnd*randombookcounter) code.
>From there, the SQL22 part fires through the table till it gets to whatever
the random line number is, and pulls the data out.
So why does it work on the main page and not the rest of them? Thats the
part that makes my brain hurt, and yours too Im guessing :)
And the images that are displaying on those pages right now arent the first
in the databse. They are from somewhere in the middle.
----------------
<%
SQL21=("SELECT * FROM t_bookstore ORDER BY aID;")
set randombook=conn.execute(SQL21)
randombookcounter = 0
Do while NOT randombook.EOF
randombookcounter = randombookcounter + 1
randombook.MoveNext
loop
randombook.close
%>
<%
pick_row88 = Int(Rnd*randombookcounter)
%>
<%
SQL22=("SELECT * FROM t_bookstore ORDER BY aID;")
set randombookdisplay=conn.execute(SQL22)
rowcount5 = 0
Do while NOT rowcount5 = pick_row88
rowcount5 = rowcount5 + 1
randombookdisplay.MoveNext
loop
Response.Write "<center><a href=booklist.asp?category=" &
randombookdisplay(2) & "><img border=0 src=" & randombookdisplay(1) &
"></a></center>"
randombookdisplay.close
%>
Christian Anderson
Photokyo - Digitally capturing the best Tokyo has to offer!
http://www.photokyo.com
More information about the thelist
mailing list