Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random images problem

Status
Not open for further replies.

meeble

Programmer
Sep 24, 2002
137
GB
Hello,

I have two sets of images:

1.jpg
2.jpg
3.jpg
4.jpg
5.jpg

and

1a.jpg
2a.jpg
3a.jpg
4a.jpg
5a.jpg

When you refresh the page, I would like different pairs of images to appear. So the first time, 1.jpg and 1a.jpg appear, the second time, 3.jpg and 3a.jpg etc.

I would like the images stored in the database. Each image would have:

unique identifier
image name
URL to go to when clicked
Image code number

How do you do this please?
 
First, you have 2 sets of images but only one image name field in the database. If you use unique IDs for the pictures you have to make another table for the relationships between these 2 sets of images. Or put another field for the 'a' images. Following example assumes you have one more field:

<%
randomize
max = 5
ID = int(rnd(1)*max) + 1 ' This is unique ID (It must be increasing continous numbers)
url = URLofImage(ID) ' Create these functions
image1 = image1OfImage(ID) ' (or one function)
image2 = image2OfImage(ID) ' that retrieves info of the unique ID specified from the database
%>

<a href=&quot;<%=url%>&quot;><img src=&quot;<%=image1%>&quot;></a>
<a href=&quot;<%=url%>&quot;><img src=&quot;<%=image2%>&quot;></a>





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top