<?php
$ad = rand(0, 5);
$site[0] = array("http://www.siteno0.gr", "siteno0.gif", "siteno0 alt");
$site[1] = array("http://www.siteno1.gr", "siteno1.gif", "siteno1 alt");
$site[2] = array("http://www.siteno2.gr", "siteno2.gif", "siteno2 alt");
$site[3] = array("http://www.siteno3.gr", "siteno3.gif", "siteno3 alt");
$site[4] = array("http://www.siteno4.gr", "siteno4.gif", "siteno4 alt");
$site[5] = array("http://www.siteno5.gr", "siteno5.gif", "siteno5 alt");
echo("<center><a href=\"".$site[$ad][0]."\" target='_blank'><img src=\"".$site[$ad][1]."\" height='60' width='468' title='Site 1' alt=\"".$site[$ad][2]."\" border='0'/></a></center>");
?>
i am using this code to generate random banner ad but i cant add it to my forum template <img src="filename.php"> doesnt deliver the image while when i point the script to the browser it works
any idea how to do it ?
Is their a specific url to the image directory?
yeah /banners/ but this aint the problem the code i posted is the original without the customization for my links/images etc. the problem is that it works when i point the php file in the browser but when i try to add it in my template by <img src="filename.php"> it doesnt work
<?php
$ad = rand(0, 5);
$site[0] = array("http://www.siteno0.gr", "siteno0.gif", "siteno0 alt");
$site[1] = array("http://www.siteno1.gr", "siteno1.gif", "siteno1 alt");
$site[2] = array("http://www.siteno2.gr", "siteno2.gif", "siteno2 alt");
$site[3] = array("http://www.siteno3.gr", "siteno3.gif", "siteno3 alt");
$site[4] = array("http://www.siteno4.gr", "siteno4.gif", "siteno4 alt");
$site[5] = array("http://www.siteno5.gr", "siteno5.gif", "siteno5 alt");
$randbanner = "<center><a href=\"".$site[$ad][0]."\" target='_blank'><img src=\"".$site[$ad][1]."\" height='60' width='468' title='Site 1' alt=\"".$site[$ad][2]."\" border='0'/></a></center>";
?>
try using that code instead and put $randbanner in your template where ever you want it to show up
i dont think that this will work . we need to call the php file somehow which is located at my root
Hi everybody!
I thinkk you can use javascript (simple - easy)
Paste this part of the code into the <head> section of your page.
------------------------
<script language="JavaScript">
// Set up the image files to be used.
var theImages = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array. Rememeber
// to increment the theImages[x] index!
theImages[0] = '100.jpg'
theImages[1] = '200.jpg'
theImages[2] = '300.jpg'
theImages[3] = '400.jpg'
theImages[4] = '500.jpg'
// ======================================
// do not change anything below this line
// ======================================
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'">');
}
//-->
</script>
Paste this part of the code into section of your page where you want the images to appear.
------------------------
<script language="JavaScript">showImage();</script>
I am interested in this using PHP to do this rather than Javascript..Anyone can help ?