Friday, June 3, 2011

What is the php code to change picture every day.?

Hi,

every day I want to choose a new picture from a folder and I am wondering if there is way to do that in javascript or I will have to use php. Anyone trying to do that?What is the php code to change picture every day.?PHP can be used to read the contents of a folder. For example, use opendir('yourfolder') to return all the filenames and check they're JPG images or whatever.



Once you have that list, you can choose which ever image you want and modify the HTML to show it. The advantage is that it'll work without JavaScript being enabled.



A JavaScript solution is possible, but JS cannot examine the content of a folder. Unless you know the filenames of all your images in advance, you'd need to use PHP to read the filenames and pass those to JavaScript in some way.



The only benefit of using JS is that you can change the image after the page has loaded; perhaps creating a slideshow like you get in the Vista sidebar.What is the php code to change picture every day.?in php it would be quite simple



get the current date and echo out the image you want.