Randomize the display of images in a folder

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Randomize the display of images in a folder
Maclain
CZ Newbie
Maclain has been a member for over 18 year's 18 Year Member
Gender: Male
Status: Offline
Joined: May 07, 2006
0.00 posts per day
Posts: 11
Points: 253
   
OK.

Being as I've been helped here before, I thought I'd pop back with yet another dilemma!

There is a site that i'm involved with, that has a list of adverts in a block on the home page.

As new sponsors come onboard, they get added to the bottom of the list.

Now some of these have (rightly so) shown a discomfort in paying to have an advert on the bottom of the page, so now what I wan't to do is have these images displayed randomly on page load.

All the images are stored in various formats in the same folder

../images/advertising

the current block: block-advertising.php has the following code


<?php

if (eregi('block-adverts.php', $_SERVER['PHP_SELF'])) {
    Header('Location: index.php');
    die();
}


$content  = "<center>";
$content .= "<p><a href=\"http://yorkshirekoi.co.uk/_launch.php?id=170\" target=\"_blank\"><img src=\"/images/advertising/mholmesmain11-07.jpg\"></a></p>";
$content .= "<br>";
$content .= "<p><a href=\"http://www.selectivekoisales.co.uk/\" target=\"_blank\"><img src=\"/images/advertising/SELECTIVEKOI11-07.jpg\"></a></p>";
$content .= "<br>";
$content .= "<p><a href=\"http://www.absolute-koi.com\" target=\"_blank\"><img src=\"/images/0308.gif\"></a></p>";
$content .= "<br>";
$content .= "<p><a href=\"http://bkksys.co.uk\" target=\"_blank\"><img src=\"/images/advertising/koimastersbanner.jpg\"></a></p>";
$content .= "<br>";
$content .= "<p><a href=\"http://www.koiplus.com\" target=\"_blank\"><img src=\"/images/koiplus140408.JPG\"></a></p>";
$content .= "<p><a href=\"http://www.shingoi.com/\" target=\"_blank\"><img src=\"/images/advertising/shingoi1.gif\"></a></p>";
$content .= "<p><a href=\"http://www.jammyfoldkoi.com/\" target=\"_blank\"><img src=\"/images/advertising/jammy.gif\"></a></p>";
$content .= "<p><a href=\"http://www.lambournkoi.co.uk/\" target=\"_blank\"><img src=\"/images/advertising/lambourn.jpg\"></a></p>";
$content .= "<p><a href=\"http://www.shingoi.com/\" target=\"_blank\"><img src=\"/images/advertising/shingoi2.gif\"></a></p>";
$content .= "<p><a href=\"http://www.yourkoi.co.uk/\" target=\"_blank\"><img src=\"/images/advertising/yourkoi.gif\"></a></p>";
$content .= "<p><a href=\"http://www.migoto-koi.co.uk/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/migotokoi.JPG\"></a></p>";
$content .= "<p><a href=\"http://www.koi-uk.co.uk/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/koiuk.png\"></a></p>";
$content .= "<p><a href=\"http://www.pastureslodge.co.uk/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/pastures.png\"></a></p>";
$content .= "<p><a href=\"http://www.richdon-koi.com/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/richdon.gif\"></a></p>";
$content .= "<p><a href=\"http://www.koicarp.org.uk/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/koiwater.jpg\"></a></p>";
$content .= "<p><a href=\"http://www.uknishikigoi.com/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/uknishi.gif\"></a></p>";
$content .= "<p><a href=\"http://www.cicscreens.co.uk/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/cicscreens.jpg\"></a></p>";

$content .= "</center>";
$content .= "<br>";
$content .= "<p><font size=\"10\"> Interested in becoming a sponsor? click <a href=\"http://bkksys.co.uk/modules.php?name=Advertising\">HERE</a>.</p></font>";


?>


As you can see, my code is probably very crude and amaturish(f7)?
Any ideas how I can either alter the block, or create a new one to display the images in a new order on each page load?

I'd also like it fairly easily editable, so as new sponsors arrive, I can add them.

Thanks in advance - Any help / advice greatly appreciated!

Chris.

P.S I'm not sure if this makes any difference, but the society involved is a non profit society. Just didn't want to think I was trying to make money from your help:-)


Back to top Reply with quote
#2   re: RAndomize the display of images in a folder
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,440
   
I made up a block for you to use.

Open it up with a text editor and add/change the $randimg to what you like. I did the first 4 from your code above.


$randimg[1] = array(
   "http://yorkshirekoi.co.uk/_launch.php?id=170", //Link
   "/images/advertising/mholmesmain11-07.jpg", //Image
   "", //image alt (mouseover text)
   "", //image width
   "" //image height
);

$randimg[2] = array(
   "http://www.selectivekoisales.co.uk/", //Link
   "/images/advertising/SELECTIVEKOI11-07.jpg", //Image
   "", //image alt (mouseover text)
   "", //image width
   "" //image height
);

$randimg[3] = array(
   "http://www.absolute-koi.com/", //Link
   "/images/0308.gif", //Image
   "", //image alt (mouseover text)
   "", //image width
   "" //image height
);

$randimg[4] = array(
   "http://bkksys.co.uk/", //Link
   "/images/advertising/koimastersbanner.jpg", //Image
   "", //image alt (mouseover text)
   "", //image width
   "" //image height
);


You can add as many as you like. There also some instructions in the file. Let me know how it goes or if you need further help.


Attached Files
block-adverts.zip (1.15 KB, Downloaded: 184 Time(s))



_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#3   
hankwill
CZ Newbie
 Codezwiz Site Donator
hankwill has been a member for over 17 year's 17 Year Member
Gender: Male
Status: Offline
Joined: Feb 18, 2007
0.00 posts per day
Posts: 1
Points: 0
   
This is very sweet. I was looking for something similar and this does exactly what I want.

Thanks Telli icon_smile.gif



Back to top Reply with quote
#4   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,440
   
I see you got it added maclain... you couldn't leave my banner in there even for just a week or so? Oh well I hope you enjoy it.




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#5   
Maclain
CZ Newbie
Maclain has been a member for over 18 year's 18 Year Member
Gender: Male
Status: Offline
Joined: May 07, 2006
0.00 posts per day
Posts: 11
Points: 253
   
Yes I got it added! Thanks for the block and the fast reply.

I've added your banner to my sig in the forums. There were issues with the the Committee members over leaving it in the main advertising block. but it should get some exposure in there!

Thanks again. Top help!



Back to top Reply with quote
#6   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,440
   
Thank You for the link back it is much appreciated. Glad it worked out for you.




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum