spidermonster
12-10-2006, 04:30 AM
I found this javascript code and want to learn more, found ajax kinda interesting too... but, with this code, I figured i could get my php banner script to rotate with seconds, instead of refresh,, well, it worked, but dont know how to get it to let me use multiple spots in one page, and not sure how its going to work with my using different size banner, and ... lol... how i can do away with the html code to view the banner, and use something different... will explain more on that later...
when you click a banner, and hit back in the browser it say error in the bottom left corner of IE, where it would normally say "Done" for the page to be loaded,,, but seams to still work ok... my major problem is that it will only let me post this one banner at the top of my page,, If I try to make copies of it and have it load another banner it has conflicts with eachother, so until I get to learning javascript more,,, think this is out of the question... because I need to post the 120x90 ads on the right no matter what,,, on my site they are more for local ads, and its how my site is designed... hate to redesign it again...
here the javascript, php code which is pulled by the include:
<script language="JavaScript">
<!--
var bannerArray = new Array();
var myCount=0;
This is the start of the php code I developed which pulles the information from a text file, and loads what I need for the banners. it also calculates how many monthes the banner spot was purchased, monthly because I dont like dealing with impressions, views or whatever,, just pay monthly, easy, fast, and other people know what they get if they are not used to advertising on the internet....
<?php
$fd =fopen ($_REQUEST[s].".txt", "r");
if ($fd)
{
$line = null;
while (!feof ($fd))
{
if (!$line)
{
// Skip header I skip one line of the text file, so the text file has how to input the information into the text file, want to make administration script later,, might want mysql later too.. but text file is how I started with...
$line = fgets($fd, 4096);
}
else
{
$line = fgets($fd, 4096);
if (strlen($line) > 10)
{
list($id,$d_start,$dur,$url,$ban,$alt,$tar,$c_name,$c_email,$c_phone) = split (",", $line, 9);
list($m,$d,$y)= split ("\/", $d_start, 3);
list($dd,$mm,$yyyy) = split("-",date("d-m-Y",time()));
$today = mktime(0, 0, 0, $mm, $dd, $yyyy);
$d_end = mktime(0, 0, 0, $m+$dur, $d, $y);
$ds = date('m/d/Y',$d_end);
if($d_end >= $today){
$c = count($line);
for($i=0;$i<$c;$i++){
echo "bannerArray[$id] = \"<A HREF='".$url."' target='".$tar."'><IMG SRC='".$ban."' border='0' alt='".$alt."'></A>\";\n";
}}}}}
fclose($fd);
}
?>
and back to the javascript I borrowed...
bannerRotate();
function bannerRotate() {
if(myCount > bannerArray.length-1){myCount=0;}
if (document.all){
document.all.l3.innerHTML=bannerArray[myCount];
}
else if (document.layers){
document.layers.l1.document.layers.l2.document.open();
document.layers.l1.document.layers.l2.document.write(bannerArray[myCount]);
document.layers.l1.document.layers.l2.document.close();
}
setTimeout("bannerRotate()", 3000);
myCount++;
}
// -->
</script>
Then I have to use this above the include,, because not my code,,, to place in the html.. I dont like using this, and if possible would like to change,,, maybe use something like <div id=banner s=728x90></div>
<font face="Tahoma" size="2">
<ilayer id="l1"></p>
<layer id="l2">
<div id="l1">
<div id="l3" style="position:relative">
</div>
</div>
</layer>
</ilayer>
</font>
is there any suggestions on how I can do this, or someone might be able to tell me where I can get a better, shorter javascript to use,, because the only reason I want the javascript is to rotate the ads in seconds, and be able to place more than one banner on a single page... kinda like this:
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="90"><tr><td align="center" valign="bottom">
<div id=banner s=120x90></div>
</td><td align="center" valign="middle">
<div id=banner s=728x90></div>
</td><td align="center" valign="bottom">
<div id=banner s=120x90></div>
</td></tr></table>
right now dont really have time to learn,, Im willing to redew all the javascript altogether, but the php ive come kinda stuck with,,, kinda hard to recode that...but have to get this script up as soon as possible, but want to learn more because found many things while searching on this feature Id like to try with my php script to make them a lil better,,, and want to learn more about this ajax because now there is another system out there to integrate it more with php... Provides PHP and JavaScript libraries for performing AJAX,,, which sounded interesting, and have it on my home server, now, just cant explain much about it yet...lol
thanks..
when you click a banner, and hit back in the browser it say error in the bottom left corner of IE, where it would normally say "Done" for the page to be loaded,,, but seams to still work ok... my major problem is that it will only let me post this one banner at the top of my page,, If I try to make copies of it and have it load another banner it has conflicts with eachother, so until I get to learning javascript more,,, think this is out of the question... because I need to post the 120x90 ads on the right no matter what,,, on my site they are more for local ads, and its how my site is designed... hate to redesign it again...
here the javascript, php code which is pulled by the include:
<script language="JavaScript">
<!--
var bannerArray = new Array();
var myCount=0;
This is the start of the php code I developed which pulles the information from a text file, and loads what I need for the banners. it also calculates how many monthes the banner spot was purchased, monthly because I dont like dealing with impressions, views or whatever,, just pay monthly, easy, fast, and other people know what they get if they are not used to advertising on the internet....
<?php
$fd =fopen ($_REQUEST[s].".txt", "r");
if ($fd)
{
$line = null;
while (!feof ($fd))
{
if (!$line)
{
// Skip header I skip one line of the text file, so the text file has how to input the information into the text file, want to make administration script later,, might want mysql later too.. but text file is how I started with...
$line = fgets($fd, 4096);
}
else
{
$line = fgets($fd, 4096);
if (strlen($line) > 10)
{
list($id,$d_start,$dur,$url,$ban,$alt,$tar,$c_name,$c_email,$c_phone) = split (",", $line, 9);
list($m,$d,$y)= split ("\/", $d_start, 3);
list($dd,$mm,$yyyy) = split("-",date("d-m-Y",time()));
$today = mktime(0, 0, 0, $mm, $dd, $yyyy);
$d_end = mktime(0, 0, 0, $m+$dur, $d, $y);
$ds = date('m/d/Y',$d_end);
if($d_end >= $today){
$c = count($line);
for($i=0;$i<$c;$i++){
echo "bannerArray[$id] = \"<A HREF='".$url."' target='".$tar."'><IMG SRC='".$ban."' border='0' alt='".$alt."'></A>\";\n";
}}}}}
fclose($fd);
}
?>
and back to the javascript I borrowed...
bannerRotate();
function bannerRotate() {
if(myCount > bannerArray.length-1){myCount=0;}
if (document.all){
document.all.l3.innerHTML=bannerArray[myCount];
}
else if (document.layers){
document.layers.l1.document.layers.l2.document.open();
document.layers.l1.document.layers.l2.document.write(bannerArray[myCount]);
document.layers.l1.document.layers.l2.document.close();
}
setTimeout("bannerRotate()", 3000);
myCount++;
}
// -->
</script>
Then I have to use this above the include,, because not my code,,, to place in the html.. I dont like using this, and if possible would like to change,,, maybe use something like <div id=banner s=728x90></div>
<font face="Tahoma" size="2">
<ilayer id="l1"></p>
<layer id="l2">
<div id="l1">
<div id="l3" style="position:relative">
</div>
</div>
</layer>
</ilayer>
</font>
is there any suggestions on how I can do this, or someone might be able to tell me where I can get a better, shorter javascript to use,, because the only reason I want the javascript is to rotate the ads in seconds, and be able to place more than one banner on a single page... kinda like this:
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="90"><tr><td align="center" valign="bottom">
<div id=banner s=120x90></div>
</td><td align="center" valign="middle">
<div id=banner s=728x90></div>
</td><td align="center" valign="bottom">
<div id=banner s=120x90></div>
</td></tr></table>
right now dont really have time to learn,, Im willing to redew all the javascript altogether, but the php ive come kinda stuck with,,, kinda hard to recode that...but have to get this script up as soon as possible, but want to learn more because found many things while searching on this feature Id like to try with my php script to make them a lil better,,, and want to learn more about this ajax because now there is another system out there to integrate it more with php... Provides PHP and JavaScript libraries for performing AJAX,,, which sounded interesting, and have it on my home server, now, just cant explain much about it yet...lol
thanks..