Forum Moderators: coopster
The only other draw back then would be that I have to actually put a php file on the server, meaning I would have to amend it every time I added or changed an image.
Thanks for your help.
Not in line with the tile of the post but.....
I heard there is a random() function to mod_include.
[ssi-developer.net...]
Might help but check if its supported on your server first if you're interested in using it :)
cheers, ject
That said, why not use the PHP include [php.net] function instead?
The only other draw back then would be that I have to actually put a php file on the server, meaning I would have to amend it every time I added or changed an image.
Not true, brow. You could put all the images in a specific directory and let PHP handle that for you, without code modifications. You could open [php.net] the directory, read [php.net] the files, and populate an array from which you would randomly select an image.
Or, better yet, use a file upload script as opposed to FTP to upload the images to the directory. At the end of the upload process, update a text file that you keep in that directory that has a comma-separated list of the files in the directory. This would eliminate the need for the server to loop through a directory on every page call. It would open and read the text file instead. I'm not sure if this would be faster or not, but I would tend to think it would be, especially once your images directory gets more populated.
Just a couple more ideas/options for you to consider.
You can do that with server side javascript ...
[faqts.com...]
as long as the directory you want to read is where the javascript files is at, but if you add a new directory, to keep things sorted out for you, then you have to add a new javascript as well.
Really it boils down to how dynamic this place you are creating is going to be. PHP does dynamic very well, Javascript is great for effects and things that happen on the browser.
My rule of thumb is if it deals with the information once it is in the browser (user clicks something or highlights something) then it is Javascript, if it is on the server and dealing with web page information PHP. If it is on the server and a utility, Perl.
But that's just me, and basically I'm lazy and don't want to work harder than I have too.
I like the sound of a file upload script... Where might I find one?
I am going to be using an image gallery called emalbum and content management (news) called Cutenews. To me it all seems very fragmented.
I am just thinking outloud, but surely I could randomise the images coming from the gallery to be shown on say my index page using another PHP file?
Can you point me in the direction of some good PHP tutorials so I am able to get my head round this? In an ideal world I would like to write my own gallery to do the above.
Thanks in advance: a very lost brow