943,946 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 4628
  • PHP RSS
Apr 1st, 2006
0

Best method to randomize image

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
stupidfly is offline Offline
36 posts
since Oct 2004
Apr 4th, 2006
0

Re: Best method to randomize image

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.
Reputation Points: 15
Solved Threads: 5
Junior Poster in Training
TopDogger is offline Offline
87 posts
since Aug 2005
Apr 4th, 2006
0

Re: Best method to randomize image

Thank you. That works wonderfully.
Reputation Points: 10
Solved Threads: 0
Light Poster
stupidfly is offline Offline
36 posts
since Oct 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: question about an include file
Next Thread in PHP Forum Timeline: upload images and store the location in a database





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC