Simple Ad Rotation PHP Tutorial

This is a very simple and easy ad rotation tutorial, you can set percentage to show the ads and you can adapt this script to rotate any thing. 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_rand" if result = 85 ad 2 will display.

|—|——————— code ——————–|—|

Leave a Reply

Your email address will not be published. Required fields are marked *