PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 307,084 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,264 people online right now. Registration is fast and FREE... Join Now!




PHP Banner Rotation How to Time Refresh?

 

PHP Banner Rotation How to Time Refresh?

Ryanmiller

27 Jun, 2009 - 12:15 AM
Post #1

New D.I.C Head
*

Joined: 20 Jun, 2009
Posts: 16


My Contributions
Here is my code, as of now it displays a new (random) banner every time the page is refreshed, how do I make it so it displays a new banner every 10 seconds instead of every page refresh? It's on a smarty .tpl file, that's why I'm using {php} and not <?php

Thanks.

CODE

{php}
$banner1 = "http://fullfiguredpersonals.com/banners/180x150_onetravel.gif";
$banner2 = "http://fullfiguredpersonals.com/banners/180x150_bevhills_skincare.gif";
$banner3 = "http://fullfiguredpersonals.com/banners/180x150_xmp3.gif";
$banner4 = "http://fullfiguredpersonals.com/banners/180x150_freshflowers.jpg";
$banner5 = "http://fullfiguredpersonals.com/banners/180x150_sandalsbeach.jpg";
$banner6 = "http://fullfiguredpersonals.com/banners/180x150_sallybeautysupplies.gif";
$banner7 = "http://fullfiguredpersonals.com/banners/180x150_priceline.gif";
$banner8 = "http://fullfiguredpersonals.com/banners/180x150_plusswimwear.jpg";
$banner9 = "http://fullfiguredpersonals.com/banners/180x150_hotelsdotcom.gif";

$address1 = "http://click.linksynergy.com/fs-bin/click?id=RNQyXSNzRGM&offerid=176450.10000246&type=4&subid=0";
$address2 = "http://click.linksynergy.com/fs-bin/click?id=RNQyXSNzRGM&offerid=173666.10000018&type=4&subid=0";
$address3 = "http://click.linksynergy.com/fs-bin/click?id=RNQyXSNzRGM&offerid=129871.10000188&type=4&subid=0";
$address4 = "http://click.linksynergy.com/fs-bin/click?id=RNQyXSNzRGM&offerid=173538.10000219&type=4&subid=0";
$address5 = "http://www.jdoqocy.com/click-3526378-10471196";
$address6 = "http://www.dpbolvw.net/click-3526378-10661837";
$address7 = "http://www.kqzyfj.com/click-3526378-10392976";
$address8 = "http://www.dpbolvw.net/click-3526378-10541288";
$address9 = "http://www.anrdoezrs.net/click-3526378-10469586";

$banner_array = array($banner1, $banner2, $banner3, $banner4, $banner5, $banner6, $banner7, $banner8, $banner9);
$address_array = array($address1, $address2, $address3, $address4, $address5, $address6, $address7, $address8, $address9);

$choose = rand(0,8);
           {/php}
<a href="{php} echo $address_array[$choose]; {/php}"><img src="{php} echo $banner_array[$choose]; {/php}"/></a>


User is offlineProfile CardPM
+Quote Post


BetaWar

RE: PHP Banner Rotation How To Time Refresh?

27 Jun, 2009 - 01:13 PM
Post #2

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 4,777



Thanked: 277 times
Dream Kudos: 1400
My Contributions
You need to use Ajax to make a new connection to the PHP file and get a different image/link then update the current image/link with the new information.

Moved to PHP
User is online!Profile CardPM
+Quote Post

RPGonzo

RE: PHP Banner Rotation How To Time Refresh?

27 Jun, 2009 - 01:20 PM
Post #3

// Note to self: hmphh .... I forgot
Group Icon

Joined: 16 Mar, 2009
Posts: 771



Thanked: 92 times
Dream Kudos: 25
My Contributions
Or you can do this using JS and set interval ... but the array would have to be re written in JS ... :-/
User is offlineProfile CardPM
+Quote Post

ShaneK

RE: PHP Banner Rotation How To Time Refresh?

27 Jun, 2009 - 03:52 PM
Post #4

require_once("brain.php"); //Fatal error :/
Group Icon

Joined: 10 May, 2009
Posts: 701



Thanked: 47 times
Dream Kudos: 75
Expert In: PHP, MySQL

My Contributions
I would go with the javascript method, seeing as how AJAX would take a lot of time just making the connection and stuff (wouldn't be much, but even 200ms can be a long time in the world of websites).

Yours,
Shane~
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 10:43AM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month