All PHP Tutorials
Ad Management
Counter
Email System
Forum and Guestbook
File Upload
Image Manipulation
Login / Members / Password
Pagination
Encode Script
Refresh / Redirection
Miscellaneous
All MySQL Tutorials
Create, Manage Database using phpMyAdmin
Connect to Database
Insert Data
Select Data
Edit Database
Update Database
Delete Database
Order Results
Forums



Home > PHP Tutorials
Simple Ad Rotation Script
Simple Ad Rotation Script
This is a very easy and simple ad rotation script, you can set percentage to show the ads and you can adapt this script to rotate any thing. 
 
  Overview

In this script (very easy script), we have 3 ads for rotation
first ad we want it to display 70%
second ad we want to display 20%
and the last one we want to display 10%

What to do

1. Random number 1-100
- if result = 1-70 (we have opportunity to display ad 1, 70%)
- if result = 71-90 (we have opportunity to display ad 2, 20%)
- if result = 91-100 (we have opportunity to display ad 3, 10%)

Example

In this script use rand(1, 100); to random number between 1 -100 and keep result in variable name "$result_random" if result = 85 ad 2 will display.


  ############### Code

<?php

// random number 1 - 100
$result_random=rand(1, 100);

// if result less than or equal 70, display ad 1 (70%)
if($result_random<=70){
echo "Display ad1";
}

// if result less than or equal 90, display ad 2 (20%)
elseif($result_random<=90){
echo "Display ad2";
}

// if result less than or equal 100, display ad 3 (10%)

elseif($result_random<=100){
echo "Display ad3";
}

?>

Random Tutorial
 
Making number format like 0001, 0002
In this tutorial we'll make number format like 0001, 0002, 0003 in stead of 1, 2 ,3. It's very easy to do this
 
Verifying email address
When users sign up to join your website you may want to verify their email address by sending confirmation link to their email address. You'll learn how to do this in this tutorial.
 
   
Hosted by Hostgator
© PHPeasystep.com 2005-2008