Hello,
I want to randomly display my adwords banner and a banner hosted on my site.
Is there any way to do this?
Here is what the adsense looks like: <script type="text/javascript"><!--
google_ad_client = "pub-9713982568167945";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
and the banner is: http://www.thepartylive.com/banners/BANNER468X60-2.gif
Basically I just want a script, similar to a random image script to alternative between these two and possibly more in the future. Any idea how I can do this?
My site for reference: http://www.volconvo.com
Thank you!
should be real easy in PHP:
$arr_images = array('<script type="text/javascript"><!--
google_ad_client = "pub-9713982568167945";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
//--></script>
<script type="text/javascript"', '<img src="http://www.thepartylive.com/banners/BANNER468X60-2.gif" alt="whatever" width="120" height="67" />')
echo array_rand($arr_images);
hey thanks for trying,
I am getting a line 2 char 8 error
is that a javascript error? check the generated html-source in your browser --> maybe you need to add linebreaks in the javascriptcode. like this
$arr_images = array('<script type="text/javascript"><!--'. "\n" .
'google_ad_client = "pub-9713982568167945";'. "\n" .
'google_ad_width = 728;'. "\n" .
'google_ad_height = 90;'. "\n" .
'google_ad_format = "728x90_as";'. "\n" .
'google_ad_type = "text";'. "\n" .
'google_ad_channel ="";'. "\n" .
'//--></script>'. "\n" .
'<script type="text/javascript"'. "\n" .
'src="http://pagead2.googlesyndication.com/pagead/show_ads.js">'. "\n" .
'</script>'. "\n", '<img src="http://www.thepartylive.com/banners/BANNER468X60-2.gif" alt="whatever" width="120" height="67" />')
echo array_rand($arr_images);
what i was trying to explain, is that you just need to have this PHP code
$arr_images = array('html-source for option1', 'html-source for option2','html-source for option3');
echo array_rand($arr_images);
macmonkey
09-21-2005, 06:36 PM
this php code should very easily work. It's definately the way to go
I agree but I cannot insert it into my header template, which is where is needs to go...only into the .php file. I would assume puting it in my .global.php would work but how do I reference it from that template?
felgall
09-21-2005, 11:25 PM
Another problem with the Javascript example is that the </script> in the code will terminate the Javascript early. Change it to <\/script> to fix that problem.
I agree but I cannot insert it into my header template, which is where is needs to go...only into the .php file. I would assume puting it in my .global.php would work but how do I reference it from that template?
without knowing your code for these pages + your filestructure, we can't really advice you on that.
ah..I am trying to insert it into a vbulletin header template
I figured out that you can insert it into a vbulletin template called php_include like this:
ob_start();
require("http://www.volconvo.com/googlerandom.php");
$arr_images = ob_get_contents();
ob_end_clean();
The result on my page though when I reference $arr_images is: $arr_images = array(''. "\n" . '
Any idea?