Hello,
here’s how to create a table with two columns, one holds an adsense block and the other one an image. The size is not fixed and will be displayed at random, it’s just to avoid quick ad blindness for new visitors and make some changes for regular visitors.
<?
// create an array with the sizes you want (beware the last array() must not have a comma at the end)
$mygoogleads = array (
array(468,60),
array(125,125),
array(234,60),
array(180,150),
array(120,240),
array(300,250),
array(250,250),
array(336,280)
);
// sort the array in random order
shuffle($mygoogleads);
// and simply take the first one (the first one begins at 0, second is 1, etc.)
$mygoogleadwidth = $mygoogleads[0][0];
$mygoogleadheight = $mygoogleads[0][1];
$mygooglecode = <<<CODE
<script type="text/javascript"><!—
google_ad_client = "pub-1234567890";
google_alternate_ad_url = "http://www.yoursite.com/images/alternate_ad_{$mygoogleadwidth}x{$mygoogleadheight}.jpg";
google_ad_width = "$mygoogleadwidth";
google_ad_height = "$mygoogleadheight";
google_ad_format = "{$mygoogleadwidth}x{$mygoogleadheight}_as";
google_ad_type = "text_image";
google_ad_channel ="1234567890";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "0000FF";
google_color_url = "000000";
google_color_text = "000000";
// —></script><script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
CODE;
// create the adsense code
$mygooglead = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">".
"<tr><td width=\"{$mygoogleadwidth}\">".$mygooglecode."</td>".
"<td width=\"5\"><img src=\"http://www.yoursite.com/images/the-stretched-image.jpg\" width=\"5\" height=\"{$mygoogleadheight}\" border=\"0\" /></td></tr></table>";
//display the code where you want in your page
echo $mygooglead;
?>Note that you can make the same with colors, or that you can add channel information in your array, like this array(468,60,”87474738738”) and use this to fill in the google_ad_channel in order to see which format has the highest CTR over a period of time.
In the code I use google_alternate_ad_url with an image url, I made as many images as I have adsense block formats in my array, I give them the name alternate_ad_WIDTHxHEIGHT.jpg but you can simply use a color or the collapsing ad unit code given by google.
At last, I’ve put the HTML code in the $mygooglead variable, this is not necessary if you just want to output the adsense code right where you write your PHP, but in my case I find it useful to have the code in a variable.
If you want more information ask in the comments here.












