PDA

View Full Version : Code to display images that change on refresh?



--ss--
01-03-2007, 09:15 PM
err somone posted it a while ago meh , i want it so every time the browser is refreshed a different image appears

redtom
01-03-2007, 09:19 PM
err somone posted it a while ago meh , i want it so every time the browser is refreshed a different image appears

Just a simple random image code?

Mentor
01-03-2007, 09:20 PM
Well it can be done more simply, but this way means its more self contained, so the code isnt actualy on the page the image is in (can be used on a few differnt pages with no new code / other sites)

http://thybag.co.uk/?p=Tutorials&ind=24

Theres a copy on habbox somewhere in tuts to i belive

timROGERS
01-03-2007, 09:22 PM
Here is a thread by me from a few weeks ago, with simple code:

http://habboxforum.com/showthread.php?t=311185

Mentor
01-03-2007, 09:31 PM
Here is a thread by me from a few weeks ago, with simple code:

http://habboxforum.com/showthread.php?t=311185

o.0 yours has a few issues, aka it doesnt have the headers to stop cacheing, plus you dont identife as a file type which will bugger it up in older browsers. o.0

Plus an array based image system saves all the counting issues

CJ-real
01-03-2007, 09:43 PM
I'm sure there are much much much much much much much much much much much much much much cleverer people than you at computers, and on this forum too: NintendoNews (no-offence, but stop being big-headed).

Mentor
01-03-2007, 10:39 PM
I'm sure there are much much much much much much much much much much much much much much cleverer people than you at computers, and on this forum too: NintendoNews (no-offence, but stop being big-headed).

Hows he being big headed? A request was made for a random image code, like me he also provided a script which would complete the task. He was being helpful not big headed?
Secondly, yea theres always some one smarter o.0 whats you point, no one in this thread has ever claimed any particularly level of intelligence, neverlown to be more intelligent than another, so what the hell your going on about, is beoned me o.0

bullwinkle
01-03-2007, 11:00 PM
wel you owned him.

Invent
02-03-2007, 12:00 PM
God do people still say 'owned' :l

But yeah, good tutorials Carl & Tim.

--ss--
02-03-2007, 03:43 PM
I basicly want to display this image : http://img64.imageshack.us/img64/1049/habbobwyk3.gif (http://imageshack.us) then on refresh it changes to http://img64.imageshack.us/img64/2343/boxhabbokb1.gif (http://imageshack.us)

Just like on http://www.habbotools.de/ under the nav the image changesafter refresh :]

will both thoose script to that? :p

Recursion
02-03-2007, 03:45 PM
Why, its just 2 Different colours of the word 'Habbo' ??? :S

--ss--
02-03-2007, 03:46 PM
Why, its just 2 Different colours of the word 'Habbo' ??? :S
Ill do other images aswell its jsut one particular example :rolleyes:

Recursion
02-03-2007, 03:52 PM
http://automaticlabs.com/products/rotator will do it, and it had some neat instructions :)

--ss--
02-03-2007, 03:54 PM
http://automaticlabs.com/products/rotator will do it, and it had some neat instructions :)
lol thanks :]

Recursion
02-03-2007, 03:56 PM
Np :) I just google'd 'Image Rotator'

TehJoshy
02-03-2007, 04:07 PM
Np :) I just google'd 'Image Rotator'

Google saves the day once again! :P

Mentor
03-03-2007, 02:09 PM
I basicly want to display this image : http://img64.imageshack.us/img64/1049/habbobwyk3.gif (http://imageshack.us) then on refresh it changes to http://img64.imageshack.us/img64/2343/boxhabbokb1.gif (http://imageshack.us)

Just like on http://www.habbotools.de/ under the nav the image changesafter refresh :]

will both thoose script to that? :p

Both scripts will.. you could even do it in javascript if you wanted, although theres no garentee of change with these as the two provied were randomisers not rotators, easy to change though.

Splinter
03-03-2007, 07:44 PM
Place this at the top of your page:


<?php
session_start();
header("Cache-Control: no-cache, must-revalidate"); // Stop cache
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Expire in the past
?>
then use this where you want the images to be shown:


<?php
$img1 = "imagetwo.gif";
$img2 = "imageone.gif";
if(!$_SESSION['image']) {
echo "<img src=\"$img1\" />";
$_SESSION['image'] = "1";
}
else {
if($_SESSION['image']=="1") {
echo "<img src=\"$img2\" />";
$_SESSION['image'] = "2";
}
elseif($_SESSION['image']=="2") {
echo "<img src=\"$img1\" />";
$_SESSION['image'] = "1";
}
}
?>
so each time the person refreshes the page the other image will show up. Since Carl and Tim's scripts are completely random where are this will show image 1 then 2 then 1. Im not sure about the cacheing stuff but I think it works.

Want to hide these adverts? Register an account for free!