Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to display diffrent image every 15 seconds without refr

Status
Not open for further replies.

DavidPlus

Programmer
Feb 20, 2007
38
NL
Hi all . I wonder if we can write a php script that once it is called using

Code:
[IMG]    [URL unfurl="true"]http://localhost/mine.php[/URL]   [/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
 
you cannot control a client using php. php is a server side process.

for non-page-refresh updates your best solution is javascript
 
There is a way to do it - if you don't have to many images (otherwise the image size could get rather large).

Dynamic Animated GIF is the way you would want to do this from the PHP side.

There is a free class available that allows you to combine the images into a GIF - the one I use is gifMerge, but it looks like an updated version is called GIFEncoder - available
If you have more than just a few images (or your images are medium to fairly large in size), then as jpadie said JavaScript is the way to go.
 
given DavidPlus other posts in the recent past, the image will change every 5 minutes to something non-foreseeable. it is album art based on a "now-playing" rss-feed.

the best answer, imo, is to use AJAX to update the image source. this would be trivial to do, require no page refreshes but it would use javascript which DavidPlus posts is to be avoided.
 
Very true jpadie,

Looking back at this post he mentions "without refreshing the whole page", and no JavaScript.

The only other thing I can think about (and I shudder as I'm typing this) is frames. It would allow refreshing of only a small portion, without javascript.
 
<script>
// (C) 2000 // // Free for all users, but leave in this header
// NS4-6,IE4-6
// Fade effect only in IE; degrades gracefully

// =======================================
// set the following variables
// =======================================

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000

// Duration of crossfade (seconds)
var crossFadeDuration = 3

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = 'images/photo_home.jpg'
Pic[1] = 'images/photo_home2.jpg'
Pic[2] = 'images/photo_home3.jpg'


var PicLink = new Array();

PicLink[0] = 'theplay.php';
PicLink[1] = 'theplay.php';
PicLink[2] ='theplay.php';



// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
preLoad = new Image()
preLoad.src = Pic
}

function runSlideShow(){
if (document.all){
document.images.SlideShow.style.filter="blendTrans(duration=2)"
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
document.images.SlideShow.filters.blendTrans.Apply()
}
document.images.SlideShow.src = preLoad[j].src
var SlideShowLink = MM_findObj('SlideShowLink');
SlideShowLink.href = PicLink[j]
if (document.all){
document.images.SlideShow.filters.blendTrans.Play()
}
j = j + 1
if (j > (p-1)) j=0
t = setTimeout('runSlideShow()', slideShowSpeed)
}
</script>


how to invoke it:

<a href="javascript:void(0);" name="SlideShowLink" id="SlideShowLink"><img src="images/photo_home2.jpg" name='SlideShow' width="132" height="236" border="0" id="SlideShow" /></a>
 
iframes with a metafresh might work. it would be a full refresh each time, but only of the iframe. good thought Borvik - agree about it being a terrible solution in the face of a decent javascriptlet.
 
I normally will put an img inside an i frame when wanting to change images. take a php photo gallery. it uses 2 frames. 1 for thumbs and the other for the pic itself. When u say play it just refreshes the pic frame and thats all.

Nice little trick to do
 
Thanks all for you reply. The problem is that url of image is recived from a rss xml feed . The feed has the url of image and there is fix time between the 2 images. That makes it hard. The reason i was looking for such solution because there are sites that does not allow any javascript!! such as myspace and fourm signature.
 
DavidPlus, I appreciate your willingness to learn, but I kind of feel like you are reinventing the wheel. I see you want assume you want to use album art as the background, and this won't quite cover it that way, but take a look here:
These are all free to use, when you sign up (which is also free). If you ignore my horrible color scheme you can see it in action at my site:
Now they also provide XML feeds which may be where you are getting yours from.

The nice thing about these images is that they are created for you, and updated automatically. They have a nice interface to change aspects of the charts, or even create your won simple ones. I can't really imagine a website you'd need to refresh the image every 15 seconds, if it is a current listening to, then you have to at least wait for the song to change an avg of 3 minutes.
 
I'd try a Flash 'widget' that polled a PHP script every x seconds. The PHP script can randomly select the image from a database/directory and pass the URL back to the Flash movie that could then do a nice transition from one to the next.

Alternately you could create a simpler Flash widget that just took a directory as a parameter and pulled images from there. Hmm is that possible?

No javascript, no page refresh and ultimately controllable as no images or urls are hardcoded into the Flash.

<honk>*:O)</honk>

Earl & Thompson Marketing - Marketing Agency Services in Gloucestershire
 
foamcow i wish i could find such a flash that read feeds for update every few seconds. Infact i want to display current song and artist played in live internet radio station that has an rss feed. I want to place that in myspace.But the problem is myspace does not allow any javascript. Do you know of any flash that can do that? It sound cool idea but most of flash that i found they have no auto update option.


Bam720. I looked at link your provied. But i still don't know if that can be used to read feed from rss and display it in myspace.
 
flash can do what you want (as i suggested above). take the time to learn its functions and interfaces - don't just use scripts created by other people. if you get stuck, ask for help in the Macromedia: flash forum (forum250)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top