Best method to randomize image

Reply

Join Date: Oct 2004
Posts: 36
Reputation: stupidfly is an unknown quantity at this point 
Solved Threads: 0
stupidfly stupidfly is offline Offline
Light Poster

Best method to randomize image

 
0
  #1
Apr 1st, 2006
Hello. What is the best method to display a random image?

I have a bunch of banners in a folder. The images are named "banner001" and the numbers ascend from there. These banners will be on the top of my pages. What is the most efficient way to randomly pick from these pictures and display them?

I don't know if PHP is even the right answer. I know I can do it by randomly picking html from a txt file, but I wanted to know if there are better ways. Thanks.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 87
Reputation: TopDogger is an unknown quantity at this point 
Solved Threads: 5
TopDogger's Avatar
TopDogger TopDogger is offline Offline
Junior Poster in Training

Re: Best method to randomize image

 
0
  #2
Apr 4th, 2006
If I understand you correctly, you just want to randomly display a banner image. The following article explains how to set up a simple PHP script to randomly display banner ads.

Simple PHP Banner Ad Rotator Script

If you just want to diplay images and not a hyperlink, just use the HTML img code in place of 'code for ad 1', etc. In other words, don't include the hyperlink code.

Place the block of PHP code in the script where you want the images to display. Also, make sure that you get the image paths correct. You do not have to use the full image URL if the images reside in your Web site.

Hope this helps.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 36
Reputation: stupidfly is an unknown quantity at this point 
Solved Threads: 0
stupidfly stupidfly is offline Offline
Light Poster

Re: Best method to randomize image

 
0
  #3
Apr 4th, 2006
Thank you. That works wonderfully.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC