Image rotation from a folder in different domain

Associate
Joined
19 Jul 2006
Posts
1,847
Right I kind of understand how rotation scripts work.
Code:
<?php

// random number 1 - 100 
$result_random=rand(1, 100);

// if result less than or equal 70, display ad 1 (70%)
if($result_random<=70){
echo "Display ad1";
}

// if result less than or equal 90, display ad 2 (20%)
elseif($result_random<=90){
echo "Display ad2";
}

// if result less than or equal 100, display ad 3 (10%)
elseif($result_random<=100){
echo "Display ad3";
}

?>

However what im after it to be able to put some code into a website that pics a random image from a folder on another domain.
I want to be able to add images to this folder afterwards which will then be included in the webpage. BUT without me having to alter any code in the webpage.

What should i be looking up


Edit: is it also posible to make the image a link. But again the links will be to different places depending on the image
 
Last edited:
Would it be doable by creating a php script that linked to a database work where each record has a referene to image location and a link location

eg
PHP:
Connect to database

Get number of rows. 

Us number of rows to get a random number then return that date.

Then use that data to populate the box
 
Not sure about PHP but if I where coding in Python it would look something like this

Read folder to count files- say 5

divide 100/files to create band size - 100/5 = 20

Create a list of numbers for absolute band assignmet - 20,40,60,80,100

Random number compared to band assignmet -

Image number based on how many thresholds you pass in list -

Print image by number -
 
Back
Top Bottom