A web site question
Author
Discussion

vex

Original Poster:

5,259 posts

276 months

Wednesday 9th August 2006
quotequote all
I want to add a small number of rotating ads to the front page of my web site.

There are two locations and I want to generate a number of different ads to appear in them, but changing to a different one each time the page is refreshed or re loaded.

Design is done using Dreamweaver (very early version) and I am happy to drop in a bit of hard code if needed.

But what code do I need, based on gif graphics call ad1, ad2, ad3 and ad4 etc.

Chris

Plotloss

67,280 posts

300 months

Wednesday 9th August 2006
quotequote all
Database to store the ad location, bit of php or javascript or similar to generate either a random number or fetchnext in a list on last used date/time order.

There are a load of plugins available for ad management.

Check out www.hotscripts.com

docevi1

10,430 posts

278 months

Wednesday 9th August 2006
quotequote all
quickest and easiest way would be to do some scripting, be it server side or client side. All you need to do is create a number of images, numbered consectively between two parameters (0 and 10 for example) and then generate a "random" number between these extremes and display the picture. It's a doddle to do in PHP / ASP and easy enough in Javascript although you are relying on the users having javascript working...

Edited by docevi1 on Wednesday 9th August 18:08

JamieBeeston

9,294 posts

295 months

Wednesday 9th August 2006
quotequote all
Rotaging Image said:

<?php
$files = glob('{*.jpg,*.gif,*.png}', GLOB_BRACE);
header("Location: {$files[array_rand($files, 1)]}";
?>


Stick that in a directory with some images in and it will show a random one each time.

J

philthy

4,697 posts

270 months

Thursday 10th August 2006
quotequote all
JamieBeeston said:
Rotaging Image said:

<?php
$files = glob('{*.jpg,*.gif,*.png}', GLOB_BRACE);
header("Location: {$files[array_rand($files, 1)]}";
?>


Stick that in a directory with some images in and it will show a random one each time.

J


.....and how would I change that script to show the newest pic in the directory ?
[/threadhijack]

JamieBeeston

9,294 posts

295 months

Thursday 10th August 2006
quotequote all
philthy said:
JamieBeeston said:
Rotaging Image said:

<?php
$files = glob('{*.jpg,*.gif,*.png}', GLOB_BRACE);
header("Location: {$files[array_rand($files, 1)]}";
?>


Stick that in a directory with some images in and it will show a random one each time.

J


.....and how would I change that script to show the newest pic in the directory ?
[/threadhijack]


I'm not a coder really, but you could sort a grep / awk / ls -lart command to display the latest.. or.. simply make the latest picture a higher number than the previous one and make an array to sort them into ascending order..

as I say, I'm no coder tho thankfully

philthy

4,697 posts

270 months

Thursday 10th August 2006
quotequote all
I was with you all the way up to "you could code sort", then it got away from me

Plotloss

67,280 posts

300 months

Thursday 10th August 2006
quotequote all
philthy said:
I was with you all the way up to "you could code sort", then it got away from me


Check out the ad management scripts on the aforementioned hotscripts.com

Makes it all very easy, you just download and install.

philthy

4,697 posts

270 months

Thursday 10th August 2006
quotequote all
Plotloss said:
philthy said:
I was with you all the way up to "you could code sort", then it got away from me


Check out the ad management scripts on the aforementioned hotscripts.com

Makes it all very easy, you just download and install.


Cheers Plotloss, any in particular you recommend? I actually want to display a webcam pic with it, and the latest would obviously be best.
Looking at the moment....