Current location: Hot Scripts Forums » Programming Languages » PHP » Is it possible to display diffrent image every 15 seconds without page refresh?


Is it possible to display diffrent image every 15 seconds without page refresh?

Reply
  #1 (permalink)  
Old 02-22-07, 04:37 AM
method method is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 228
Thanks: 0
Thanked 0 Times in 0 Posts
Arrow Is it possible to display diffrent image every 15 seconds without page refresh?

Hi all . I wonder if we can write a php script that once it is called using [img] and [/img]
It showes diffrent pics every 15 seconds without refreshing the whole page. i be happy if some show me how this can be done all inside php without any javascript.Thanks

Last edited by method; 02-22-07 at 04:48 AM.
Reply With Quote
  #2 (permalink)  
Old 02-22-07, 04:46 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
This is not possible with PHP alone. You need Javascript to achieve this.
Reply With Quote
  #3 (permalink)  
Old 02-22-07, 09:27 AM
Shaffer Shaffer is offline
Wannabe Coder
 
Join Date: Sep 2006
Location: Israel
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Nico View Post
This is not possible with PHP alone. You need Javascript to achieve this.
Why? You can make a function that uses SetTimeOut(15000) where you call the query in it making an infinite loop (ofcourse you must tell the function to echo the result or change the source of the image, which is easier done with JavaScript, yes.


Shaffer.
__________________
Hello from Israel!
Reply With Quote
  #4 (permalink)  
Old 02-22-07, 10:12 AM
method method is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 228
Thanks: 0
Thanked 0 Times in 0 Posts
shaffer i know in javascript it can be done. But as you know most invasion power boards does n't allow any javascript on the singnature that is why i look for php way . could u show me how this can be done if you think it is possible?Thanks
Reply With Quote
  #5 (permalink)  
Old 02-22-07, 10:34 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
There is one way to use only PHP, but you wouldn't be able to add or subtract images very easly. You could create an animated gif with all your images in it, set with 15 sec intervals between images. The animated gif would run continually, flipping thru the images.
__________________
Jerry Broughton

Last edited by job0107; 02-22-07 at 10:36 AM.
Reply With Quote
  #6 (permalink)  
Old 02-22-07, 02:22 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Quote:
Originally Posted by Shaffer View Post
Why? You can make a function that uses SetTimeOut(15000) where you call the query in it making an infinite loop (ofcourse you must tell the function to echo the result or change the source of the image, which is easier done with JavaScript, yes.


Shaffer.
How? SetTimeOut() is a Javascript function, and he doesn't want to refresh the page. How do you tell PHP to dynamically change an image without refreshing the page? Doesn't sound possible to me...
Reply With Quote
  #7 (permalink)  
Old 02-23-07, 06:23 AM
Shaffer Shaffer is offline
Wannabe Coder
 
Join Date: Sep 2006
Location: Israel
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Hello,
Nico, I suppose you're right, I got mixed-up.
Job0107, it could be done dynamically, by getting all of the images from a database or xml, making a gif out of them, and then set them a 15 second interval.


Shaffer.
__________________
Hello from Israel!
Reply With Quote
  #8 (permalink)  
Old 02-25-07, 06:01 PM
phpdoctor's Avatar
phpdoctor phpdoctor is offline
Code Guru
 
Join Date: Feb 2007
Location: New Zealand
Posts: 767
Thanks: 4
Thanked 2 Times in 2 Posts
Reply With Quote
  #9 (permalink)  
Old 02-27-07, 10:13 AM
Crassius Crassius is offline
Newbie Coder
 
Join Date: Mar 2006
Location: Melbourne, FL
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
I'm gonna go out on a limb here and try this:
(note: i'm not gonna test this code, i'm just throwing it out, play with it.)

PHP Code:

<?php
$imgcount 
0;
for(
$i=0$i<15000$i++){
    if(
$i=='14900'){
        
$imgcount++;
        
$i 0;
    }
    if(
$imgcount=='15'){
        
$imgcount=0;
    }
    
}

?>
Name your files (example: 1.jpg, 2.jpg --> 14.jpg)

then <?php echo "<img src=$imgcount.jpg>"; ?>

Now the problem lies in making the page refresh, the code i gave will make it change the file name every 15seconds ish, but it won't refresh the image display.
You'll need javascript for that. Read up on some ajax i guess.

Ok, so i probably didn't help much, but hey, i gave it a shot.
__________________
~With great power comes great responsibility.~

Last edited by Nico; 02-27-07 at 12:27 PM.
Reply With Quote
  #10 (permalink)  
Old 02-27-07, 10:23 AM
method method is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 228
Thanks: 0
Thanked 0 Times in 0 Posts
crasss. thanks for your reply. so if if i call a php script using [img] and [/img]
and inside that php there is javascript. Do you think the image will will change every few seconds ?
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically refresh page after page load failure jdugger JavaScript 3 08-05-10 09:16 AM
Please Help! Display Records page by page peter_toronto PHP 5 02-20-08 09:12 AM
[turnkey] Lyrics site - $149 (LEGAL) rightinpoint General Advertisements 0 10-22-06 04:33 AM
retreived data and display data upon choice from first page? benq PHP 0 05-06-06 05:45 AM


All times are GMT -5. The time now is 05:56 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.