473,387 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Rotating images in a folder using php scripts

pradeepjain
563 512MB
hii this is a new problem

I need to read a folder and then take the images from there and display it in such a way tht after a certain time the neaxt image has to be taken ..in the sense it has to rotate all the images...any basic idea to do it..

thanks
pradeep
Aug 8 '07 #1
6 6718
kovik
1,044 Expert 1GB
I'm not sure where the rotation came from... I think you need to explain what you want more clearly.
Aug 8 '07 #2
nathj
938 Expert 512MB
hii this is a new problem

I need to read a folder and then take the images from there and display it in such a way tht after a certain time the neaxt image has to be taken ..in the sense it has to rotate all the images...any basic idea to do it..

thanks
pradeep
Do you perhaps mean that you would like to loop through the images listed in the directory? Like a simple Flash movie but done with PHP?

Cheers
nathj

Ps I also replied to this post when you submitted under your previous thread
Aug 8 '07 #3
pradeepjain
563 512MB
[PHP]<?
$imglist='';
//$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/
// see that you don't forget about the "/" at the end
$img_folder = "files/slide/";

mt_srand((double)microtime()*1000);

//use the directory class
$imgs = dir($img_folder);

//read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners)
while ($file = $imgs->read()) {
if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
$imglist .= "$file ";

} closedir($imgs->handle);

//put all images into an array
$imglist = explode(" ", $imglist);
$no = sizeof($imglist)-2;

//generate a random number between 0 and the number of images
$random = mt_rand(0, $no);
$image = $imglist[$random];

//display image
echo '<img src="'.$img_folder.$image.'" border=0>';
?>

[/PHP]



i wrote this code and some part is cut and paste..can any one explain me wht is
[PHP]mt_srand((double)microtime()*1000);[/PHP]......i did read the php manual..but nothing went into my head..plzz explain this

wht this code is doing is tht when i refresh the page the image changes...but wht i wnt is lttle bit different....can any one help...the images must continously rotating one after the other...the one in the site lke
in the right hand side www.iiap.res.in
Aug 8 '07 #4
nathj
938 Expert 512MB
i wrote this code and some part is cut and paste..can any one explain me wht is
[PHP]mt_srand((double)microtime()*1000);[/PHP]......i did read the php manual..but nothing went into my head..plzz explain this

wht this code is doing is tht when i refresh the page the image changes
This code is, I believe, producing a random number using the microtime etc as the seed for that number. So every time you refresh the page a new number is generated and so a new image is displayed.

...but wht i wnt is lttle bit different....can any one help...the images must continously rotating one after the other...the one in the site lke
in the right hand side www.iiap.res.in
This site is using javascript to achieve this, I'm not sure how to do that as I don't use a lot of javascript. I'm sure iot must be possible in PHP but I ahve never done it and so I don't know.

Cheers
nathj
Aug 8 '07 #5
pradeepjain
563 512MB
This code is, I believe, producing a random number using the microtime etc as the seed for that number. So every time you refresh the page a new number is generated and so a new image is displayed.



This site is using javascript to achieve this, I'm not sure how to do that as I don't use a lot of javascript. I'm sure iot must be possible in PHP but I ahve never done it and so I don't know.

Cheers
nathj

oh ok..wht is double and 1000 ......?????..hve u used drupal tool
Aug 9 '07 #6
nathj
938 Expert 512MB
oh ok..wht is double and 1000 ......?????..hve u used drupal tool
These are simply used to generate the seed for the 'randomn' number generator - mt_srand().

I have never used drupal

Cheers
nathj
Aug 9 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Ian Hubling | last post by:
I'm trying to complete a rotating banner ad within a page I have. The rotating add has four images that rotate in three-second increments. I've got the images to rotate ok - but now I want to go...
1
by: Sandy Bremmer | last post by:
I have seen many Javascripts that rotate images with each load or refresh of the page but so far all I've found require hard coding the image filename into the script. Does anyone know of a script...
1
by: Grunt | last post by:
Hi, I have been trying to put together a rotating banner. the code works but I am having a problem with the caching of the banner images. no matter what I try the page is constantly reloading the...
31
by: Royal Denning | last post by:
I am designing a table with 2 columns and 20 rows. I want to insert small images (each with a link) and a text title in each cell of the table. On refresh of the page, I would like to have the...
14
by: mikeoley | last post by:
Why would this script below work on an html page: http://www.eg-designdev.com/aircylinders/test.htm But not a java page such as this: "http://www.eg-designdev.com/aircylinders/index3.jsp" Or...
15
by: Jameson | last post by:
Happy New Year, Everyone! I am trying to figure out how to display a bunch of images (mainly JPEGs, but possibly a few GIFs and PNGs as well) that are stored in a local directory on the system....
2
by: sgMuser | last post by:
Hi, I am not a good developer of Javascript codes. Needs this help to make some modification to this famous free javascript from Anarchos. i am using this in one of my webpage. What it does is,...
3
by: Beamer | last post by:
Hi I am trying to build a roating slide effect in javascript. Basically, I have a list like below <ul id="slideShowCnt"> <li id="slide0"><img .../></li> <li id="slide0"><img .../></li> <li...
1
by: Sunshine192 | last post by:
Hi, I'm still kinda new to PHP so I could do with some advice. I'm using the code below to select and show a random image from a folder of images. rotate.php <?php // Make this the relative...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.