Welcome to Dream.In.Code
Getting PHP Help is Easy!

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




Reloading A Php Page?

2 Pages V  1 2 >  
Reply to this topicStart new topic

Reloading A Php Page?

Markp
post 26 Oct, 2002 - 06:34 PM
Post #1


D.I.C Head

**
Joined: 18 Jan, 2002
Posts: 76

I have a simple banner add script on www.internationaldrugsbaron.com

All it does is grab a random line from a text file and display it.

How can I refresh that random line (pick a new line) without reloading the whole page... is that possible?

This is my simple banner code...
CODE
<?php
function randomline($filename) {
$file = file($filename);
 srand((double)microtime()*1000000);
 while ($randomquote == "") {
  $randomquote = ereg_replace("\n","",$file[rand(0,count($file))]);
 }
 echo $randomquote;  
}  
?>
User is offlineProfile CardPM

Go to the top of the page

fyrestorm
post 26 Oct, 2002 - 06:51 PM
Post #2


D.I.C Lover

Group Icon
Joined: 4 Apr, 2002
Posts: 3,103



Thanked 2 times

Dream Kudos: 228
My Contributions


do you mean that you want you're banner to change without the page refreshing?
User is offlineProfile CardPM

Go to the top of the page

The Neoracle
post 26 Oct, 2002 - 07:47 PM
Post #3


Check, check, 1, 2.

Group Icon
Joined: 30 Mar, 2001
Posts: 4,069



Thanked 1 times
My Contributions


If you want to keep it the same way you have it (PHP), you can't do it without refreshing the page.

You could put a java applet on there and it could refresh without refreshing the page, but PHP has to be processed by the server, and therefore the page must be reloaded
User is offlineProfile CardPM

Go to the top of the page

Markp
post 26 Oct, 2002 - 08:04 PM
Post #4


D.I.C Head

**
Joined: 18 Jan, 2002
Posts: 76

The banner php page, is different to the page it is included in...

So if I want the banner on index.php I use:
CODE
<!-- Banner Code -->
<? include("../banners3/banners3.php"); ?>
<? randomline("../banners3/banners3.txt"); ?>
<!-- Banner Code End-->


To include the file... is there a way around it, now that it is a seperate file?
User is offlineProfile CardPM

Go to the top of the page

LuxFX
post 27 Oct, 2002 - 08:43 AM
Post #5


D.I.C Head

**
Joined: 9 Aug, 2001
Posts: 63

as RDS was saying, PHP is a server-side language, and operates once -- including all of the php includes and other processing -- before the page loads, and then send the result to the client. and that's the end of the PHP, the server releases it like an abandoned child and thinks of it no more.

for what you want to do, I would put the banner in an IFRAME on the page. This can be loaded seperately, and can be triggered through javascript or a META <refresh> tag to reload itself. It has to reload so that the server will be forced to process the PHP again.

here are some other options:
1) use JS/DHTML to write the banner on-the-fly, and then use the .innerHTML tags to alert the text. advantages: no reloads, or extra server communication needed. disadvantages: all possibilities must be contained in the original page. you don't have to load every image if you want to swap images too, but you have to have the text of the image location to plug into the HTML later

2) use flash to display the banner/text -- or at least the text. Advantages: you can format it pretty, and take care of all the server communication through flash. Disavantages: unless your banner images are in swf form, or you have preloaded them all into the flash movie, if you want to dynamically change your images your users will need flash6 player to load extra images.

3) you can use various combinations of these options. for instance, you can use an invisible flash movie to connect to the server and retreive the new banner/text, and then send that back to the Javascript, which can update the page with JS/DHTML and the .innerHTML tag.

cheers!
LuxFX
User is offlineProfile CardPM

Go to the top of the page

gneato
post 27 Oct, 2002 - 09:36 AM
Post #6


<title>Untitled Document</title>

*****
Joined: 3 Sep, 2001
Posts: 1,311

holy shit, that's a long reply...
flash or java... there are ways w/ javascript too... but it's a pain in the ass
User is offlineProfile CardPM

Go to the top of the page

gneato
post 27 Oct, 2002 - 09:37 AM
Post #7


<title>Untitled Document</title>

*****
Joined: 3 Sep, 2001
Posts: 1,311

one thought I had was...

an iframe with the ads inside

the iframe reloads then...
User is offlineProfile CardPM

Go to the top of the page

iamcenz
post 27 Oct, 2002 - 08:57 PM
Post #8


You wish you were my hand!

Group Icon
Joined: 26 Mar, 2001
Posts: 2,385



Dream Kudos: 201
My Contributions


QUOTE(gneato @ Oct 27 2002, 01:37 PM)
one thought I had was...

an iframe with the ads inside

the iframe reloads then...

thats what i was gunna say to do
User is offlineProfile CardPM

Go to the top of the page

Markp
post 30 Oct, 2002 - 08:48 PM
Post #9


D.I.C Head

**
Joined: 18 Jan, 2002
Posts: 76

QUOTE(gneato @ Oct 27 2002, 11:37 AM)
one thought I had was...

an iframe with the ads inside

the iframe reloads then...

yup... thats the way I was going smile.gif Not sure if Iframes work in all browsers though?
User is offlineProfile CardPM

Go to the top of the page

gneato
post 30 Oct, 2002 - 11:09 PM
Post #10


<title>Untitled Document</title>

*****
Joined: 3 Sep, 2001
Posts: 1,311

they work in most, I do believe
User is offlineProfile CardPM

Go to the top of the page

klewlis
post 31 Oct, 2002 - 08:16 AM
Post #11


cur tu me vexas?

*****
Joined: 9 Nov, 2001
Posts: 1,723

If I'm understanding your first post correctly, you are only displaying text in this ad? There is no image involved?

If that's the case, shouldn't it be as simple as defining an element and changing it periodically with javascript?
User is offlineProfile CardPM

Go to the top of the page

fyrestorm
post 31 Oct, 2002 - 08:31 AM
Post #12


D.I.C Lover

Group Icon
Joined: 4 Apr, 2002
Posts: 3,103



Thanked 2 times

Dream Kudos: 228
My Contributions


QUOTE(klewlis @ Oct 31 2002, 10:16 AM)
If I'm understanding your first post correctly, you are only displaying text in this ad? There is no image involved?

If that's the case, shouldn't it be as simple as defining an element and changing it periodically with javascript?

well, even if it were an image, couldn't you just use some javascript to make it change periodically?
User is offlineProfile CardPM

Go to the top of the page

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 02:14AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month