| | |
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 |
apache api array autocomplete beginner binary body broken cakephp class cms code cron curl database dataentry date date/time display duplicates dynamic ebooks email emptydisplayvalue error execute explodefunction file firstoptioninphpdroplist folder form forms function functions google href htaccess html image include ip javasciptvalidation javascript joomla keywords limit link list login matching mediawiki menu msqli_multi_query multiple mycodeisbad mysql navigation number oop parameter paypal pdf php phpincludeissue query random recourse recursive regex script search seo server sessions shot source sp space speed sql static subdomain subscription system table tag tutorial tutorials update upload url validator variable vbulletin video web webdesign white xml youtube





