As you know adsense only allows only 3 ad units per site. So it can get a bit 'boring' to see the same ad format over and over again. So it would be good for your pages to dynamically display random adsense ads, from the various available from google. here is simple PHP code I have come up with to randomly display adsense ads on your site. Put this code where ever you want the adsense ad to appear :


// If you have 3 ads - if you want four the its (1, 4) etc

$random = rand(1, 3);

// store the full path and filename
$filename = "$_SERVER[DOCUMENT_ROOT]/toplevel/nextlevel/adsdirectory/$random.php";

// get the random adsense ad
include ("$filename");


NB :

change this "/toplevel/nextlevel/adsdirectory/"

to whatever absolute path your 1.php, 2.php....n.php ads are held in (eg from your top level directory to the directory where you ads are held).

Make a new php file for every ad and insert the adsense adcode in it. And name them 1.php 2.php 3.php (if you have 3 ads) etc.

and your done !!