Cannot get this one correct and working, though simple!

This is a discussion on Cannot get this one correct and working, though simple! within the PHP Language forums, part of the PHP Programming Forums category; I have 40 or jpeg files which I want them displayed in a frame called "main" upon clicking ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-30-2005
Jofio
 
Posts: n/a
Default 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

Reply With Quote
  #2 (permalink)  
Old 12-30-2005
Lüpher Cypher
 
Posts: n/a
Default Re: Cannot get this one correct and working, though simple!

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
Reply With Quote
  #3 (permalink)  
Old 12-30-2005
Peter Fox
 
Posts: n/a
Default Re: Cannot get this one correct and working, though simple!

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
peterfox@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Reply With Quote
  #4 (permalink)  
Old 12-30-2005
Geoff Berrow
 
Posts: n/a
Default Re: Cannot get this one correct and working, though simple!

Message-ID: <IU5yAgAsnQtDFw$+@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/
Reply With Quote
  #5 (permalink)  
Old 12-30-2005
Jerry Stuckle
 
Posts: n/a
Default Re: Cannot get this one correct and working, though simple!

Geoff Berrow wrote:
> Message-ID: <IU5yAgAsnQtDFw$+@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.
jstucklex@attglobal.net
==================
Reply With Quote
  #6 (permalink)  
Old 12-30-2005
comp.lang.php
 
Posts: n/a
Default Re: Cannot get this one correct and working, though simple!


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

Reply With Quote
  #7 (permalink)  
Old 12-30-2005
Geoff Berrow
 
Posts: n/a
Default Re: Cannot get this one correct and working, though simple!

Message-ID: <1135959418.255476.21750@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/
Reply With Quote
  #8 (permalink)  
Old 12-30-2005
Oli Filth
 
Posts: n/a
Default Re: Cannot get this one correct and working, though simple!

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
Reply With Quote
  #9 (permalink)  
Old 12-30-2005
Geoff Berrow
 
Posts: n/a
Default Re: Cannot get this one correct and working, though simple!

Message-ID: <E_adnTHBbOGRzyjeRVn-uA@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/
Reply With Quote
  #10 (permalink)  
Old 12-30-2005
Oli Filth
 
Posts: n/a
Default Re: Cannot get this one correct and working, though simple!

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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:33 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0