View Full Version : Random Banner

The Wizzard
01-19-2003, 08:01 AM
Hey Everyone...

Lets say that I have 8 banners in my database...

And I want to display 4 at a time.

How can I randomly select 4 from the database?


01-19-2003, 07:33 PM
Well, as for selecting 8 banners out of a database you will need to assign an ID number to them. 1-8.

Here is the randomizing code for the numbers you have, so only 4 will show, and to make it alot easier for you, the 4 numbers are all different so you don't see the same banner twice.

Work with this, this is the only hard part in making what you need. It will help you in ASP to figure out the rest for yourself. But still ask questions if you don't understand.


Dim IntRandom(3), I, J


For I = 0 To 3

IntRandom(I) = Int(8 * Rnd() + 1)

For J = 0 To 3

If IntRandom(I) = IntRandom(J) And IntRandom(I) <> 0 And I <> J Then
I = I - 1
Exit For
End If



For I = 0 To 3
Response.Write IntRandom(I) & "<br>"