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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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> |
|
|||
|
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/ |
|
|||
|
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 ================== |
|
|||
|
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 |
|
|||
|
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/ |
|
|||
|
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 |
|
|||
|
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/ |
|
|||
|
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 |