Link to home
Create AccountLog in
Avatar of fedkris
fedkris

asked on

show random images (asp)

i wanna show an image random with the text

exemple: image 1, text 1

image 2, text 2


the text random works, but when i want to show the image, it doens't work, someone ideas's? i don't see any image...

thx

kristof

<%

if len(request("lng"))>0 then
	session("id_language") = request("lng")

else
	session("id_language") = "nl"
end if


set rst2 = server.CreateObject("ADODB.Recordset")
strsql2= " SELECT COUNT(idimage) AS total FROM dbo.image GROUP BY visible HAVING (visible = N'1')"

rst2.Open strsql2,Application("connection_db")
if rst2.bof and rst2.eof then
totaal = 0
else
totaal = rst2("total")
end if 


limit= totaal
redim textefr(limit) 

set rst = server.CreateObject("ADODB.Recordset")

strsql = "SELECT dbo.image.text" & session("id_language") & " as mijntext, dbo.image.image, dbo.List_Event.Titre_" & session("id_language") & " as mijntitel, dbo.image.visible, dbo.List_Event.id_event as id_event"
strsql= strsql& " FROM   dbo.image INNER JOIN dbo.List_Event ON dbo.image.id_event = dbo.List_Event.id_event"
strsql= strsql& " WHERE     (dbo.image.visible  = N'1')"

                 
rst.Open strsql,Application("connection_db")
if rst.bof and rst.eof then
else	
	i=1
	do while not rst.eof	
	
	
		mytext2 = "<a href='http://event.comeos.be/default.asp?contenu=event&id_event=" & rst("id_event") & "&lng=" & session("id_language") & "' target='_blank'>"
		mytext2 = "<img src='http://event.comeos.be/image/pics/" & rst("image") & ".png'>"
		mytext2 = mytext & "" & rst("mijntitel") & "</a>&nbsp;&nbsp;" & rst("image") & "	<br><br>" & rst("mijntext") & " <strong>" & rst("mijntitel") &"</strong>"
		
		
	textefr(i) = mytext2
	%>
	<%
	
	i=i+1
	rst.movenext
	loop
	
	
	rst.close
	
randomize
random=int(rnd*limit)+1

response.write textefr(random)

end if 
%>

Open in new window

Avatar of pateljitu
pateljitu
Flag of Canada image

Can you please change code from line 39-41, seems like concatenation was not correct:

		mytext2 = "<a href='http://event.comeos.be/default.asp?contenu=event&id_event=" & rst("id_event") & "&lng=" & session("id_language") & "' target='_blank'>"
		mytext2 =  mytext2 &"<img src='http://event.comeos.be/image/pics/" & rst("image") & ".png'>"
		mytext2 = mytext2 & "" & rst("mijntitel") & "</a>&nbsp;&nbsp;" & rst("image") & "	<br><br>" & rst("mijntext") & " <strong>" & rst("mijntitel") &"</strong>"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer