PDA

View Full Version : Looping and time delayed calls to PHP routine



DogCatcher
11-18-2008, 04:07 PM
I am using a rotating ad banner with links to display multiple sponsor logo and web link information. The php script is resident on a page in the site that is accessed by a call within the body of the page that the ad appears on. The ads are changed when the page is reloaded and remain until the page is reloaded. I want to use a timed repeat loop on the calling page to repeatedly call the script. Repeated calls would occur on about a 5 second interval. I want this to be resident on a php page.

Does anyone have ideas of how to do this?:bawling:

DogCatcher

mobilebadboy
11-19-2008, 04:21 AM
As it sits that's not possible. PHP is a server-side script, meaning it has to be processed through the software on the server before it can display end results to the browser (which is client side). The page has to be reloaded for the php script to process new results then return them to the page.

One option is to use an iframe within your main page and load another page in to it that contains your ad code/script. Then set up a meta-refresh (http://www.google.com/search?q=meta%2drefresh) on the ad code page so it reloads within the iframe.

DogCatcher
11-19-2008, 06:11 AM
Thanks mobilebadboy for the response. Do you have any sample code for the main page that shows how to construct the iframe within it?

mobilebadboy
11-19-2008, 06:29 AM
Where your current ad code is displayed in the page, add the following (since I don't know the width/height of the ads being displayed, just change the values in the iframe to match if needed).


<iframe src ="ads.php" width="468" height="60" frameborder="0" scrolling="no"></iframe>

Then create a new file called ads.php and add this to it along with your ad code.



<html>
<head>
<meta http-equiv="refresh" content="5">
</head>
<body style="margin:0; padding:0">

// PUT YOUR AD CODE HERE

</body>
</html>

You'll probably have to tweak things to your liking, but that's the basics.

DogCatcher
11-19-2008, 08:31 AM
I will try this! My GREAT appreciation for the help!

DogCatcher

NYWonders
08-28-2009, 09:20 AM
I am using a rotating ad banner with links to display multiple sponsor logo and web link information. The php script is resident on a page in the site that is accessed by a call within the body of the page that the ad appears on. The ads are changed when the page is reloaded and remain until the page is reloaded. I want to use a timed repeat loop on the calling page to repeatedly call the script. Repeated calls would occur on about a 5 second interval. I want this to be resident on a php page.

Does anyone have ideas of how to do this?:bawling:

DogCatcher

DogCatcher,

A php script is only executed once per call. You might be intrested in a type of javascript called "ajax". Basicly, in your html page sent to the client, you would execute a java script every 5000ms, that would call your php script and insert it a section of you page. I use a simular technique to update the users online every 1000ms on my page. Only other way is to run a flash program on your page, or group your banners as a gif format. for more information about ajax, google "javascripts ajax tutorial".
Sorry, I couldn't have been more help.

NYWonders - http://nywonders.us/