html rotation

CSalt2

Power Member
Joined
Feb 5, 2009
Messages
761
Reaction score
361
does anyone know how i can rotate html with a code or something

I'm trying to have the code automatically rotate through flash banners, but when i use a banner rotator it doesn't perform the function that I'd like it too.
 
Last edited by a moderator:
This is a pretty ghetto way to go about doing that, but it works.
PHP:
<?php
$embedFlash[] = '<code></code>';
$embedFlash[] = '<code></code>';
$embedFlash[] = '<code></code>';

$rotate_count = (count($embedFlash)-1);
$rotate = mt_rand(0,$rotate_count);

echo $embedFlash[$rotate];

?>

You can add as many $embedFlash[] = 'blah'; lines as you want and it'll rotate them randomly. Make sure that whatever HTML you're embedding only contains double-quotes (") and not single-quotes (') or it'll throw an error.
 
<edit>Damn you beat me to it :D</edit>

Well if you're using php...

PHP:
blah blah some shit

<?php

$banners = array(
'<a href="gay.com">some link</a>',
'<a href="gay.com">some link</a>',
'<a href="gay.com">some link</a>'
);

shuffle($banners);
echo $banners[0];

?>

blah blah more shit
 
here's a 50% rotation script gimme shared

Code:
<?php
// Creates random number between 1 and 100
$rand = rand(1,100);

if ($rand>50){
?>
Flash code here
<?php
}else{
?>
Other flash code here
<?php } ?>
 
Back
Top