| | |
Best method to randomize image
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2004
Posts: 36
Reputation:
Solved Threads: 0
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.
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.
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.
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.
![]() |
Similar Threads
- Css Fixed Background Attachment (Site Layout and Usability)
- Resizing images from a SQL DataBase (ASP.NET)
- Thumbnailed images (PHP)
- Image problem in Scroll Pane (Java)
- JPanel and putting a Background GIF pic...NOT WORKING (Java)
- Onclick questions (HTML and CSS)
- Help! Scanning through each image pixel... (Java)
Other Threads in the PHP Forum
- Previous Thread: question about an include file
- Next Thread: upload images and store the location in a database
| Thread Tools | Search this Thread |
301 access apache api array autocomplete beginner binary broken button cakephp checkbox class cms code compression cron curl data database dataentry date display dropdown dropdownlist duplicates dynamic echo email error execution file files folder form forms function functions google href htaccess html htmlspecialchars httppost image include insert integration ip javascript joomla jquery limit link links login mail md5 menu methods mlm multiple mysql oop paypal pdf pdfdownload php phpvotingscript query radio random recursion remote script search secure server session sessions source space sql subscription syntax system table tutorial tutorials update upload url validator variable video virus volume votedown web youtube





