Skip to main content
Known Participant
May 22, 2006
Answered

images rotating

  • May 22, 2006
  • 2 replies
  • 475 views
I have the page, when it first loads; it displays image1 with all the text1 for description1 for this image1. If I refresh the page, then it display different image and text description suppose image2 and text2 for description2 and so on until image5 and text5. Every time the page it loads, it appears different image. Is anyone done something like this? Can you guys help?

Thanks
This topic has been closed for replies.
Correct answer jimWPX
Do Query of image and text

<cfquery name="weeklySpecials" datasource="yourDB">
SELECT mypic, Special_Price, ProductTitle from mytable
</cfquery>

<cfset RandomItem = RandRange(1, weeklySpecials.recordcount)>
<CFOUTPUT QUERY="WeeklySpecials" MAXROWS=1 STARTROW=#RandomItem#>
<img src='images/#mypic#' height="200" width="300"><br/>
<B>#ProductTitle#</B> - #DollarFormat(WeeklySpecials.Special_Price)#<br/>
</CFOUTPUT>

2 replies

jimWPXCorrect answer
Inspiring
May 22, 2006
Do Query of image and text

<cfquery name="weeklySpecials" datasource="yourDB">
SELECT mypic, Special_Price, ProductTitle from mytable
</cfquery>

<cfset RandomItem = RandRange(1, weeklySpecials.recordcount)>
<CFOUTPUT QUERY="WeeklySpecials" MAXROWS=1 STARTROW=#RandomItem#>
<img src='images/#mypic#' height="200" width="300"><br/>
<B>#ProductTitle#</B> - #DollarFormat(WeeklySpecials.Special_Price)#<br/>
</CFOUTPUT>
newcfAuthor
Known Participant
May 22, 2006
Thanks alot guys.
May 22, 2006
I took the code below from my personal home page. It displays one of 12 images randomly when the page is loaded. You can modify it to suit your specific needs.