benh48
05-05-2006, 09:45 AM
Hello,
I am in need of a text banner rotator. But instead of rotating randomly in need it to rotate based on the day of the year. Does anyone know if such a text rotator exists. I have been doing google searches but only find rotators that are random.
Thanks in advance
dgeorge
05-05-2006, 10:56 AM
Maybe something like this ??
http://www.finalwebsites.com/snippets.php?id=18
benh48
05-05-2006, 04:34 PM
Yeah, thanks. I am looking for something like that but without having to us a database. I would like to be able to access a simple .txt file that holds the actual data then display one each day.
dgeorge
05-05-2006, 04:56 PM
I have not test this but it should work using a flat text file or at least get you close ;)
$strAdFile = "temp.txt";
$strDelimenter = "||";
// get day of year
$intThisDayoFYear = date("z"); // 0-365
// read ads into an array
$arrAds = file($strAdFile);
// if day of year index is in ad file split on delemiter
$arrAdDetails = array();
if(isset($arrAds[$intThisDayoFYear])){
$arrAdDetails = explode($strDelimenter,$arrAds[$intThisDayoFYear]);
}
// if split was good show ad else show a default placeholder ad or none
if(count($arrAdDetails) == 2){
$strAdContent = '<a href="'.$arrAdDetails[0].'">'.$arrAdDetails[1].'</a>';
}else{
$strAdContent = 'SOME DEFAULT AD INCASE THERE IS A FILE CORRUPTION?READ ERROR!';
}
// echo our ad
echo $strAdContent
/*
temp.txt content (1 ad per line):
http://www.something.com||text for link
http://www.something2.com||text for link2
*/