PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I was imagining the best way to develop a kind of ROTATE TEXT INFORMATIONS AS FOLLOWS:
I place a single TXT file inside a dir called: ADVERTISE.
But I want to output this file as <? include("./advertise/text.txt")?> into my INDEX PAGE on the right col of my table.
All texts in TEXT FILE is separate by ";". So turning simple to use SPLIT to break in identifies each block text to display correctly on a give limit TIME.
All I want to do now is on every 5 min the code REFRESHES and take the next TEXT BLOCK as a BANNER ROTATOR.
I read some documents but did not find the best clue to finish this. Can anyone here give a "clue" to put me in the right path?
Thank You Very Much !
Kind Regards,
Poeta_Eletrico
put the output into an iframe, then use a meta page refresh pointing to the output page set for the time you want. The page it points to in the refresh should be somthing like http://www.pageToRefresh.php?ad=1, Then in the pageToRefresh.php, you simply use $_GET['ad'] to choose the next advert, and set the meta refresh tag to http://www.pageToRefresh.php?ad=2 so that the next ad shows and so on...
define('ADFILE', 'advertise/text.txt');
define('ROTATIONTIME', 300); //every 5 minutes
//calculate the difference between current time and the adfile time
$timediff = time() - filemtime(ADFILE);
//get the ads
$ads = explode(';', file_get_contents(ADFILE));
$totalads = count($ads);
if($timediff > (ROTATIONTIME * $totalads)){
//reset the rotation
touch(ADFILE);
$currentad = 1;
} else {
//get the current advert
$currentad = ceil($timediff / ROTATIONTIME);
}
//echo out the current advert
echo $ads[$currentad - 1];