473,386 Members | 1,820 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,386 software developers and data experts.

Cannot get this one correct and working, though simple!

I have 40 or jpeg files which I want them displayed in a frame called
"main" upon clicking thumbnails of the same pics in a "leftMenu" frame.
The thumbnail jpeg files are called thumb1, thumb2, thumb3, thumb4,
...., thumb40. These files are smaller versions (50pixelX50pixel) of the
larger jpeg files called 1, 2, 3, 4, ..., 40 which I want them
displayed.

To display the hyperlinked thumbnails in the "leftMenu" frame I have it
in a loop. [See the code snippet]

But my problem is that part of the code ...<img src='thumb$i.jpg'> ...

It doesn't display the intended thumbnail jpeg files; instead, it
display the larger version of the files as thumbnails which takes
longer to load.

Here's my loop:

<?php
for ( $i = 1; $i < 40; $i++) {
if ($i!=17) {
echo "<a href='$i.jpg' target='main'><img src='thumb$i.jpg'></a>

}
}
?>

Any help? Many thanks in advance.
jofio

Dec 30 '05 #1
15 1464
Jofio wrote:
I have 40 or jpeg files which I want them displayed in a frame called
"main" upon clicking thumbnails of the same pics in a "leftMenu" frame.
The thumbnail jpeg files are called thumb1, thumb2, thumb3, thumb4,
..., thumb40. These files are smaller versions (50pixelX50pixel) of the
larger jpeg files called 1, 2, 3, 4, ..., 40 which I want them
displayed.

To display the hyperlinked thumbnails in the "leftMenu" frame I have it
in a loop. [See the code snippet]

But my problem is that part of the code ...<img src='thumb$i.jpg'> ...

It doesn't display the intended thumbnail jpeg files; instead, it
display the larger version of the files as thumbnails which takes
longer to load.

Here's my loop:

<?php
for ( $i = 1; $i < 40; $i++) {
if ($i!=17) {
echo "<a href='$i.jpg' target='main'><img src='thumb$i.jpg'></a>

}
}
?>


This should work perfectly well.. Check the left frame source - the
<img> tags should have thumbs as sources. If they do, check the size of
the thumb files - perhaps, they are large?

luph
Dec 30 '05 #2
Following on from Jofio's message. . .
But my problem is that part of the code ...<img src='thumb$i.jpg'> ...


Single quotes! Try Double.
--
PETER FOX Not the same since the adhesive company came unstuck
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Dec 30 '05 #3
Message-ID: <IU**************@eminent.demon.co.uk> from Peter Fox
contained the following:
But my problem is that part of the code ...<img src='thumb$i.jpg'> ...


Single quotes! Try Double.


Single quotes are fine as is the code AFAICT.

--
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/
Dec 30 '05 #4
Geoff Berrow wrote:
Message-ID: <IU**************@eminent.demon.co.uk> from Peter Fox
contained the following:

But my problem is that part of the code ...<img src='thumb$i.jpg'> ...


Single quotes! Try Double.

Single quotes are fine as is the code AFAICT.


No, with single quotes $i is not expanded. It would be with double quotes.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Dec 30 '05 #5

Jofio wrote:
I have 40 or jpeg files which I want them displayed in a frame called
"main" upon clicking thumbnails of the same pics in a "leftMenu" frame.
The thumbnail jpeg files are called thumb1, thumb2, thumb3, thumb4,
..., thumb40. These files are smaller versions (50pixelX50pixel) of the
larger jpeg files called 1, 2, 3, 4, ..., 40 which I want them
displayed.

To display the hyperlinked thumbnails in the "leftMenu" frame I have it
in a loop. [See the code snippet]

But my problem is that part of the code ...<img src='thumb$i.jpg'> ...

It doesn't display the intended thumbnail jpeg files; instead, it
display the larger version of the files as thumbnails which takes
longer to load.

[snip]

The problem lies in the way you embedded $i. PHP thinks you have a
variable literally called "$i.jpg" since a period is a valid implied
variable name character.

Try this instead:

<img src='thumb${i}.jpg'>

curly braces will separate out the valid variable name characters.

Phil

Dec 30 '05 #6
Message-ID: <11*********************@g14g2000cwa.googlegroups. com> from
comp.lang.php contained the following:
The problem lies in the way you embedded $i. PHP thinks you have a
variable literally called "$i.jpg" since a period is a valid implied
variable name character.
It is? News to me.
Try this instead:

<img src='thumb${i}.jpg'>

curly braces will separate out the valid variable name characters.


No, what he's got works, his problem is elsewhere.

See:-

<?php

$i=1;

print"<img src='thumbs$i.jpg'>";

//outputs <img src='thumbs1.jpg'>
?>

--
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/
Dec 30 '05 #7
comp.lang.php said the following on 30/12/2005 16:16:
Jofio wrote:

But my problem is that part of the code ...<img src='thumb$i.jpg'> ...


The problem lies in the way you embedded $i. PHP thinks you have a
variable literally called "$i.jpg" since a period is a valid implied
variable name character.


Umm, no... Who told you that?

The problem is the use of single quotes rather than double quotes.

--
Oli
Dec 30 '05 #8
Message-ID: <E_********************@comcast.com> from Jerry Stuckle
contained the following:
Single quotes! Try Double.

Single quotes are fine as is the code AFAICT.


No, with single quotes $i is not expanded. It would be with double quotes.


Looking at the code again he has

echo "<a href='$i.jpg' target='main'><img src='thumb$i.jpg'></a>

Now that can't be right or he's have a parse error, so I assumed he had

echo "<a href='$i.jpg' target='main'><img src='thumb$i.jpg'></a>";

which, for $i =1 gives:-
<a href='1.jpg' target='main'><img src='thumb1.jpg'></a>

In which case it would be in double quotes and would be expanded. In
fact the OP had already said it was expanded.
--
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/
Dec 30 '05 #9
Oli Filth said the following on 30/12/2005 16:40:
comp.lang.php said the following on 30/12/2005 16:16:
Jofio wrote:

But my problem is that part of the code ...<img src='thumb$i.jpg'> ...
The problem is the use of single quotes rather than double quotes.


Actually, no, my bad - misread the OP's code.

But the point out the . still holds.

--
Oli
Dec 30 '05 #10
Jerry Stuckle wrote:
Geoff Berrow wrote:
Message-ID: <IU**************@eminent.demon.co.uk> from Peter Fox
contained the following:

But my problem is that part of the code ...<img src='thumb$i.jpg'> ...

Single quotes! Try Double.

Single quotes are fine as is the code AFAICT.


No, with single quotes $i is not expanded. It would be with double quotes.


Single quotes *within* double quotes, as the OP had, do not stop PHP
from interpolating the variables!

Try it

<?php
$name = 'Jerry';

echo "Name is $name"; /* only double quotes */
echo 'Name is $name'; /* only single quotes */
echo "Name is '$name'"; /* single quotes *within* double quotes */
echo 'Name is "$name"'; /* double quotes *within* single quotes */
?>

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Dec 30 '05 #11
Thank you all for helping. It is working now... Once again, many
thanks..
jofio

Jan 2 '06 #12

Oli Filth wrote:
comp.lang.php said the following on 30/12/2005 16:16:
Jofio wrote:

But my problem is that part of the code ...<img src='thumb$i.jpg'> ...

The problem lies in the way you embedded $i. PHP thinks you have a
variable literally called "$i.jpg" since a period is a valid implied
variable name character.


Umm, no... Who told you that?


The PHP manual. Assuming that is still your authority on PHP.

"Variable names follow the same rules as other labels in PHP. A valid
variable name starts with a letter or underscore, followed by any
number of letters, numbers, or underscores. As a regular expression, it
would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'"
From http://us3.php.net/language.variables
Sorry to be off-topic.

Phil

The problem is the use of single quotes rather than double quotes.

--
Oli


Jan 3 '06 #13
comp.lang.php said the following on 03/01/2006 17:50:
Oli Filth wrote:
comp.lang.php said the following on 30/12/2005 16:16:
Jofio wrote:

But my problem is that part of the code ...<img src='thumb$i.jpg'> ...

The problem lies in the way you embedded $i. PHP thinks you have a
variable literally called "$i.jpg" since a period is a valid implied
variable name character.
Umm, no... Who told you that?


The PHP manual.


No it didn't.

"Variable names follow the same rules as other labels in PHP. A valid
variable name starts with a letter or underscore, followed by any
number of letters, numbers, or underscores. As a regular expression, it
would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'"
Where is a period mentioned in that quote?
Indeed, as a counter-quote from the manual: "However, it should be noted that the dot (period, full stop) is not
a valid character in a PHP variable name."

(http://www.php.net/manual/en/languag...l.dot-in-names)

Think about it - it's the string concatenation operator - how could it
be used as a character in a variable name?
--
Oli
Jan 3 '06 #14
I wrote something last year that sort of does what you want see this for example

http://www.allelsefailedind.com/2005/gallery.php

it's a gallery in frame and you click on the thumb and it shows the larger one on the right.
I have 400 images and they are all in a folder, then I used a tool thumbnail express to
create the thumbs for the frame, then I used some php to make the thing work
if you need more detailed explanation and example write me at
ja******@hotmail.com


On 29 Dec 2005 22:31:34 -0800, "Jofio" <j9******@yahoo.com> wrote:
I have 40 or jpeg files which I want them displayed in a frame called
"main" upon clicking thumbnails of the same pics in a "leftMenu" frame.
The thumbnail jpeg files are called thumb1, thumb2, thumb3, thumb4,
..., thumb40. These files are smaller versions (50pixelX50pixel) of the
larger jpeg files called 1, 2, 3, 4, ..., 40 which I want them
displayed.

To display the hyperlinked thumbnails in the "leftMenu" frame I have it
in a loop. [See the code snippet]

But my problem is that part of the code ...<img src='thumb$i.jpg'> ...

It doesn't display the intended thumbnail jpeg files; instead, it
display the larger version of the files as thumbnails which takes
longer to load.

Here's my loop:

<?php
for ( $i = 1; $i < 40; $i++) {
if ($i!=17) {
echo "<a href='$i.jpg' target='main'><img src='thumb$i.jpg'></a>

}
}
?>

Any help? Many thanks in advance.
jofio


Jan 5 '06 #15
Yes, similar page...but I am developing it on my PC. Thanks..I
enjoyed your gallery.

Jofio

Jan 9 '06 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/authoring-faq Posting-Frequency: twice a week (Mondays and Thursdays) Last-modified: August 28, 2002 Version: 1.15 URL: http://css.nu/faq/ciwas-aFAQ.html...
0
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/authoring-faq Posting-Frequency: twice a week (Mondays and Thursdays) Last-modified: April 10, 2003 Version: 1.16 URL: http://css.nu/faq/ciwas-aFAQ.html Maintainer:...
17
by: DanielESFA | last post by:
Hey guys :) This is a bit of a funny one... We're four guys working on the same project, everybody using KDevelop and g++ on Linux. Three of us are using Mandrake, with g++ 3.4.3 and 3.4.1....
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
10
by: Jean-David Beyer | last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2 V6.1 (with all the FixPacks) on my old machine. I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat...
4
by: newgenre | last post by:
I set up a simple page with vs.net. It's kust an html page and I'm trying to get people to the site through the internet. My server is Windows XP and I use IIS as the server. The problem is that I...
19
by: Andy B | last post by:
Hello, Sorry for this newbish question. Briefly, my problem: ------------------ I expect the database I'm working on to reach something in the order of 12-16 Gigabytes, and I am interested...
18
by: Pedro Pinto | last post by:
Hi there once more........ Instead of showing all the code my problem is simple. I've tried to create this function: char temp(char *string){ alterString(string); return string;
4
by: eschneider | last post by:
I get the following error when trying to browse the .asmx. I get the same thing when trying to add a reference. using .NET 2.0 There is no error message. Any ideas? Thanks,
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.