By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,711 Members | 2,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,711 IT Pros & Developers. It's quick & easy.

Using The Same Page To Display A Hundred Pictures One Picture At A Time

P: n/a
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.

Also, I think I'm running into some problems whereby the
javascript is messing up Google's parsing of the page.

I don't see creating 100 different html pages as an answer,
in the respect if something ever changes, that's one big mess
to update and major portion of the content and alot of files.
Am I wrong in trying to avoid doing it via strictly HTML
pages?

The pages exist at, and they represent swimming pools designed
by the owner of Aquatic Creations (North Carolina In-Ground
Swimming Pool Designers):

Custom Swimming Pool Water Features
http://aquaticcreationsnc.com/lib/php/viewing0.php
Custom Designed Swimming Pools
http://aquaticcreationsnc.com/lib/php/viewing1.php
Custom Designed Spas
http://aquaticcreationsnc.com/lib/php/viewing2.php
Custom Swimming Pool Features
http://aquaticcreationsnc.com/lib/php/viewing3.php
Stone And Tile Around Swimming Pools
http://aquaticcreationsnc.com/lib/php/viewing4.php

Does anyone have any suggestions on how to accomplish such
or directions to pursue?

If you could take a look as well and provide comments on the
pages, I appreciate constructive criticism as well.

Thanks much,

Jim Carlock
Post replies to the newsgroup.
Jan 29 '06 #1
Share this Question
Share on Google+
13 Replies


P: n/a
"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."

Have you considered using sessions? You could use them to create a
temporary cache of the array quite easily.

<?php
session_start();
if (!isset($_SESSION['array_cache'])) {
$array = array('value', 'value');
$_SESSION['array_cache'] = $array;
} else {
$array = $_SESSION['array_cache'];
}
?>

Jan 29 '06 #2

P: n/a
Al
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.

Jan 29 '06 #3

P: n/a
Just download the program I used in my other thread to do all of it for
you. It is completely free and very powerful.

http://groups.google.com/group/comp....2f6061b4fe1d58

Now if you could be so kind as to tell me why the heck PHP isn't
working on this new web I would appreciate it. ;-)

Brent

Jan 30 '06 #4

P: n/a
<br*********@lyricvault.com> wrote:
Now if you could be so kind as to tell me why the heck PHP
isn't working on this new web I would appreciate it. ;-)


I believe for IIS you right click inside the MMC for IIS on the
website in question, then click upon Properties..., and thereby
set the ISAPI ext to include PHP.

There might be a way to set up the appropriate PHP dll for all
sites, but I'll let you tell me that. Make sure you employ the DLL
(as opposed to putting PHP in the path and employing php.exe).

Hope this helps.

Jim Carlock
Post replies to the newsgroup.
Jan 30 '06 #5

P: n/a
<xc*****@gmail.com> posted:
Have you considered using sessions? You could use them to create
a temporary cache of the array quite easily.


<?php
session_start();
if (!isset($_SESSION['array_cache'])) {
$array = array('value', 'value');
$_SESSION['array_cache'] = $array;
} else {
$array = $_SESSION['array_cache'];
}
?>

Thanks, Clark(?). I'll give that a go.

Jim Carlock
Post replies to the newsgroup.
Jan 30 '06 #6

P: n/a
Al
Jim Carlock wrote:
<xc*****@gmail.com> posted:
Have you considered using sessions? You could use them to create
a temporary cache of the array quite easily.


<?php
session_start();
if (!isset($_SESSION['array_cache'])) {
$array = array('value', 'value');
$_SESSION['array_cache'] = $array;
} else {
$array = $_SESSION['array_cache'];
}
?>

Thanks, Clark(?). I'll give that a go.

Jim Carlock
Post replies to the newsgroup.


I admit I don't know the internal workings of PHP too well, but I'm
really not sure storing the array as a session variable will actually
help anything.
As far as I can tell session variables are just little text files
stored server-side per connection. As such there are two points:

1) you're just loading the array from a text file, so it makes no
difference whether you're loading it from the text file or creating it
in the script

2) it may actually be serialised to be put in said text file, and as
such you're actually incurring extra time serialising and unserialising
it every page refresh.

Plus even if this way does manage to save some server processing (in a
way I can't see) then it'll only work on subsequent page loads of each
session. As such the array still has to be created once per
user/session of the web site. If the array isn't going to change it
might be best to create the array and serialise it to a text file
that's open for everyone. That way the script can just load it from
there even for the first load per session. And if it only changes every
now and again (i.e. with an update from you rather than in the script
over a session) then you can make a separate script that will load it
in, make the changes, and then save it again.

But I could be way off with the way sessions work.

Feb 1 '06 #7

P: n/a
"Al" <al************@gmail.com> wrote:
<snip>...</snip>

The way it exists currently, the javascript fails to help in regards
to search engines. Each image carries some associated text, and
soon it will carry the following independent items:

<meta name="description" ... />
<meta name="keywords" ... />
<title>Independent Title</title>
<h1>Independent Heading For the Image</h1>
<p>Independent text for the image in question.</p>

And the page to view the image will contain keywords...

I'm trying to figure out which will work better of the following two
methods. The goal is to help address search engines and create
a server side manner in which to display the pages, employing
keywords in the addressbar.

(1) swimmingpool.php?id=1
(2) view.php?type=swimmingpool&id=1
or by getting rid of the numerical identifiers...
(3) view.php?type=customswimmingpool&pool=customguitar pool

Keywords for each image and search engines are the goals. I
wanted to avoid creating independent HTML pages, but that might
represent the best way to go as far as search engines goes, and
place them inside the appropriate folders on the server.

Some people try to change the text on images to get Google to
come back to their website more often. But I tend to think that
Google probably caught onto that a long time ago and drops
everything after the question mark (?). I imagine Google might
skip changing dates as well. For instance if the only thing that
changes on the page is a current date...

What the owner of the website really wants is to get their
name to the top of the google search engine when someone
types in:

<a href="http://aquaticcreationsnc.com">Raleigh Swimming Pool Builder</a>

Along with a couple other things... So I might need to work that
into the ?title=RaleighSwimmingPoolBuilder&swimmingpool=1

Those are my thoughts, and I'm kind of hesitating and exploring
other options before I push into one way or the other.

It took Google 3 months to grab the website, which should only
really be one month. Based upon my initial tests in the past, it
only takes a month to get a webpage recognized by Google,
when only one link is created inside a newsgroup.

Hope that helps explain why I decided to move in the server
side direction. The javascript works nicely, as far as displaying
images goes. I've read some things though that indicate that
Google doesn't run as a javascript client and therefore tends
to miss everything that goes on with the webpage as it exists
right now. I don't know how long I'm going to have wait
before google picks up on the page...

http://aquaticcreationsnc.com/lib/php/viewing0.php

And thanks for commenting that the images are nice. I
normally reduce the size and change some things, they
are quite big at the moment, but then again, the people
that they're targeting are people with big homes and fast
internet connections, so I left the images as 300Kb files.
Gif's tend to become problematic for Internet Explorer
machines as well. If you open one of those images up
inside of Internet Explorer then open another browser
up, if your machine isn't the latest greatest top of the
line, you notice the images acting funny when browsed
by Internet Explorer.

Thanks for your suggestions Al. Hope this helps.

Jim Carlock
Post replies to the newsgroup.
Feb 2 '06 #8

P: n/a
For arrays of arrays, how do I access the "ani/pic-1.gif" element?

$aImages = array("custom_pools", array(array("ani/pic-1.gif",
"Replica 1974 Gibson Les Paul Guitar", "pic-1.jpg",
"description", "pagetitle", "metadescription", "metakeywords",
"<h1>h1</h1>"),

I tried $aImages[0][0] but that returns "c".
I then tried $aImages[0][1], and that returns "u".
I then tried $aImages[0][0][0] and that returns an empty string.

I did get another array(array to return the proper values, but now
that I placed a string as the first element and an array of arrays as
the second element... :-z

Thanks.

Jim Carlock
Post replies to the newsgroup.
Feb 4 '06 #9

P: n/a
Jim Carlock wrote:
For arrays of arrays, how do I access the "ani/pic-1.gif" element?

$aImages = array("custom_pools", array(array("ani/pic-1.gif",
"Replica 1974 Gibson Les Paul Guitar", "pic-1.jpg",
"description", "pagetitle", "metadescription", "metakeywords",
"<h1>h1</h1>"),

I tried $aImages[0][0] but that returns "c".
I then tried $aImages[0][1], and that returns "u".
I then tried $aImages[0][0][0] and that returns an empty string.


try

echo '<pre>'; print_r($aImages); echo '</pre>';

--
If you're posting through Google read <http://cfaj.freeshell.org/google>
Feb 4 '06 #10

P: n/a

Jim Carlock wrote:
"Al" <al************@gmail.com> wrote:
<snip>...</snip>

The way it exists currently, the javascript fails to help in regards
to search engines. Each image carries some associated text, and
soon it will carry the following independent items:

<meta name="description" ... />
<meta name="keywords" ... />
<title>Independent Title</title>
<h1>Independent Heading For the Image</h1>
<p>Independent text for the image in question.</p>

And the page to view the image will contain keywords...
You're going to need to create (or have php create for you) separate
pages then. That doesnt mean that your curent JS gallery is out of the
question though. You can have it both ways. You need to make your
prev/next buttons be a real link and a js trigger:

<a href="/view.php?album=pools&pic=guitar.jpg"
onClick="JSfunctionThatShowsTHeNextPic(); return false"><img
src="/NextPicIcon.jpg"></a>

That will do the next pic in JS for most users, and for non JS browsers
and google, it will work like a regular link. (well, I know it works
for non-JS users, I dont know for certain about google)

You've got to get php to do all that figuring out for you though.

Here's what you're going to do:
1. look in the specified folder, make a list (array) of the picture
files.
2. go through the list, read in the key words and other text that
matches each pic from a DB or txt files.
3. spit out the JS and the html to make the gallery and the keywords.

I'm trying to figure out which will work better of the following two
methods. The goal is to help address search engines and create
a server side manner in which to display the pages, employing
keywords in the addressbar.

(1) swimmingpool.php?id=1
(2) view.php?type=swimmingpool&id=1
or by getting rid of the numerical identifiers...
(3) view.php?type=customswimmingpool&pool=customguitar pool
How 'bout
pool-custom-guitar.htm

You need .htaccess to tell mod_rewrite to 'rewrite' your URL. It will
take the URL above and translate it into:
view.php?type=custom&pool=guitar

(by the way, send those boys up to my house, I'd like one of those
guitar pools. Make mine a tele, though ;)
Keywords for each image and search engines are the goals. I
wanted to avoid creating independent HTML pages, but that might
represent the best way to go as far as search engines goes, and
place them inside the appropriate folders on the server.

Some people try to change the text on images to get Google to
come back to their website more often. But I tend to think that
Google probably caught onto that a long time ago and drops
everything after the question mark (?). I imagine Google might
skip changing dates as well. For instance if the only thing that
changes on the page is a current date...


For what it's worth, google doesnt seem to have a problem with indexing
my ugly php urls...
--
j

Feb 4 '06 #11

P: n/a
Jim Carlock wrote:
For arrays of arrays, how do I access the "ani/pic-1.gif" element?

$aImages = array("custom_pools", array(array("ani/pic-1.gif",
"Replica 1974 Gibson Les Paul Guitar", "pic-1.jpg",
"description", "pagetitle", "metadescription", "metakeywords",
"<h1>h1</h1>"),

I tried $aImages[0][0] but that returns "c".
I then tried $aImages[0][1], and that returns "u".
I then tried $aImages[0][0][0] and that returns an empty string.

I did get another array(array to return the proper values, but now
that I placed a string as the first element and an array of arrays as
the second element... :-z

Thanks.

Jim Carlock
Post replies to the newsgroup.


$aImages[0] is "custom_pools", so it's returning exactly what it's
supposed to - the first or second character in the string.

$aImages[1][0][0] is "ani/pic-1.gif". You also have $aImages[1][0][1],
$aImages[1][0][2], etc.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Feb 4 '06 #12

P: n/a
"Pedro Graca" <he****@dodgeit.com> answered:
try

echo '<pre>'; print_r($aImages); echo '</pre>';
Thanks, Pedro. That's going to be indispensable when messing with
arrays. I've done that with PHP's built-in arrays. The power of
suggestion... Thanks!

Jim Carlock
Post replies to the group.

Jim Carlock originally posted/asked: For arrays of arrays, how do I access the "ani/pic-1.gif" element?

$aImages = array("custom_pools", array(array("ani/pic-1.gif",
"Replica 1974 Gibson Les Paul Guitar", "pic-1.jpg",
"description", "pagetitle", "metadescription", "metakeywords",
"<h1>h1</h1>"),

I tried $aImages[0][0] but that returns "c".
I then tried $aImages[0][1], and that returns "u".
I then tried $aImages[0][0][0] and that returns an empty string.

Feb 4 '06 #13

P: n/a
Message-ID: <11**********************@g47g2000cwa.googlegroups .com> from
juglesh contained the following:
(by the way, send those boys up to my house, I'd like one of those
guitar pools. Make mine a tele, though ;)


Strats are more shapely :)

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Feb 4 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.