PHP Banner Rotation Script

Tutorial showing how to create a banner rotation script with PHP.

Before you read the Tutorial about Banner Rotation, it is recommended that you read Variables in PHP Which includes information about Array's, and finally String Concatenation.

Creating The Script

Can also be used to rotate images

The first Example is really simple, and sufficient in most cases.

<?php

$RandomNumber = rand(1, 10);

echo '<img src="Images/' . $RandomNumber . 'img.jpg">';

?>

The above asume that you already know the name of the images, simply name each image "1img.jpg, 2img.jpg, 3img.jpg" Etc. And then increase the random number accordingly.

Post comment

Links that you insert are not nofollowed, but will be removed by admins if they are considered spam.

[url=Absolute URL for page]TITLE[/url]

You should insert code boxes around code examples, which will be automatically syntax highlighted.

[code1 html|css|javascript|php|sql]Your Code Here[/code1]

You may want to read our Privacy Policy before submitting your comment.