Thread Rating:
- 0 Votes - 0 Average
- 1
- 2
- 3
- 4
- 5
|
Simple Random Banner in PHP
|
| Author |
Message |
Admin
Administrator
      
Posts: 54
Joined: Nov 2009
Reputation: 0
|
Simple Random Banner in PHP
Requirements :-
1. Notepad
Copy the code Below
Code:
<?php
$banner_src[0]="banners/banner01.gif";
/* replace "banners/banner01.gif" with the location to your first banner image */
$banner_link[0]="http://www.linkrelatedtobanner.com";
/* replace "http://www.linkrelatedtobanner.com" with the url you want people to go to
when they click your first banner */
//reapeat as above for 2nd, 3rd banner etc.....
$banner_src[1]="banners/banner02.gif";
$banner_link[1]="http://www.linkrelatedtobanner02.com";
$banner_src[2]="banners/banner03.gif";
$banner_link[2]="http://www.linkrelatedtobanner03.com";
$banner_src[3]="banners/banner04.gif";
$banner_link[3]="http://www.linkrelatedtobanner04.com";
/*The above code has created 2 arrays, one array of image
urls and another array for the links that go with them. You can
add as many as you like, increasing the number in the
[square brackets] by 1 as you do. */
$banner_count=((count($banner_src))-1);
/*this line counts how many banners you have in your arrays,
but since arrays start at number 0, we minus 1 from the count*/
$which_banner=(rand(0, $banner_count));
/*this line picks a random number between 0(the start of our array)
and the current banner count */
/*this next bit of code displays the chosen banner as a link */
print "<center><a href=\"$banner_link[$which_banner]\" target=\"_blank\">
<img src=\"$banner_src[$which_banner]\" border=\"0\"></a></center>";
?>
Now save the file as "banner.php"
use this code where u want banner to display
Code:
<?php include("banner.php"); ?>
Use this code where ever u want banner to display
|
|
| 11-28-2009 06:34 PM |
|