You are here: Re: Using The Same Page To Display A Hundred Pictures One Picture At A Time « PHP Programming Language « IT news, forums, messages
Re: Using The Same Page To Display A Hundred Pictures One Picture At A Time

Posted by Al on 10/09/73 11:38

Jim Carlock wrote:
> I have over a hundred pictures I would like to present.
>
> Is it practical to create and parse an array of pictures,
> picture paths, et al using server-side scripting to
> accomplish this?
>
> I created an array already, and whereby, the HTML and Javascript
> currently used amount to about 14KB for each of four different
> pages, the PHP page I started working on is already over 35KB in
> size (most of it is server side processing creating the array of
> pictures).
>
> What I'd like to do, is load the array only one time, and keep that
> loaded so the page doesn't recreate the array each time, thus
> minimizing the server side array creation.

First, cool animations :)

Also, I'm not sure exactly what it is that you want to do? What's the
problem with server-side array creation? The problem is that whatever
you do you'll HAVE to load that data in somehow. If you used the
session cookies as has been mentioned you still have a 30-odd-kB array
to go through, if you load it in from a file you still have the array.
There is one way you can do it so you don't have the whole array in
memory at one time, and that's using a database. That way you're just
pulling the bit of the 'array' that you need at any one time, however I
think the database route is a little surplus to requirements in this
situation.

At the moment you're using javascript to change the picture on the fly
without resorting to a page reload but if I'm reading your post
correctly you wouldn't mind if the page had to be refreshed to change
the picture, as long as the html for it was small.

In which case PHP can indeed help you. Just have the large array as a
PHP array and have certain parameters on the command (url) line. For
instance you say you have about 100 pictures, well in the array they'll
be given the indices 0 to 99 (or whatever) so you can pass something
like getpicture.php?picturenum=30 to get a particular picture. That's
simple enough and should output a relatively small HTML page (as you
will no longer have the javascript.)

The problem comes when you need to have that thumbnail bar. If that's
done as static HTML then you can only have one bar for each image, and
thus for the user to be able to see all three preview bars they'll have
to go to three different areas of pictures. However you CAN do it using
javascript like you currently are but this'll bring your page's size
back up. Still, you won't have the large array in the outputted
html/javascript and so it'll still be quite small.

Basically I think what you need to do (and what you're pretty much
wanting to do) is get the large array out of the html (so it isn't
downloaded every time) but keep the same functionality. And doing it in
PHP using the method I've explained will do this for you. Remember it
doesn't matter if the PHP file is 100kB of array processing, the
outputted html page can be as small as you like.

If you want a more detailed explanation with some sample code then say
so and I'll do my best to come up with something usable, but I think
you get the gist of what you need to do. Basically get all of that
javascript array processing out of the html and into the PHP file. It's
as simple as that.


Of course if that's NOT what you wanted then sorry if I've been
patronising or anything, and feel free to clarify your problem.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация