Zend - The PHP Company




HTML

Add Code


Banner Rotator by Nuthan Krishnan  

Type: application
Added by: webcoder
Entered: 11/12/2000
Last modified: 01/12/2000
Rating: - (fewer than 3 votes)
Views: 6276
This php application reads a text file containing a list of banners and the time in seconds to display on the screen. The application will construct the proper javascript after reading the text file from the server. It loads each banner, display it on the screen, the specified number of seconds. The list of banners and time can be freely edited. The format of the text file (timer.txt) is as follows: first.gif 3000 =waits for 3 seconds second.gif 4000 =waits for 3 seconds third.gif 5000 =waits for 3 seconds email:nuthankrishnan@hotmail.com


<html>
<script>

piks=new Array();                                
timsec=new Array();                              

an_image=new Array();                             
                                                 
<?
$file
=fopen("timer.txt","r");                                   
$num=0;                                  
$stat=1;
$gn=0;

while(
$stat)
{
$stat=fgets($file,100);                            
        if (!
$stat)
            {
                 break;
                 }
$arr[$num]=$stat;
$giftime=split(" ",$arr[$num]);                         
echo 
"piks[".$gn."]=".'"'.$giftime[0].'";'."n";
echo 
"timsec[".$gn."]=".$giftime[1].";n";
$gn++;
$num++;
}
?> 

           for (i=0;i<piks.length;i++)
          {
            an_image[i]=new Image();
            an_image[i].src=piks[i];
                  } 

var i;
i=0;
j=0;

function rotate()
{
document.images[0].src=an_image[i].src;
uptill=timsec[j];
i++;
j++;
if (i>piks.length-1)
{
i=0;
j=0;
}
setTimeout("rotate()",uptill);
}
</script>
 
<body bgcolor=ivory onload=rotate();>

<center><img src=one.gif></center>

</body>

</html>


Usage Example




Rate This Script





Search



This Category All Categories