Skip to main content
Inspiring
September 5, 2008
Question

PHP IF/ELSE

  • September 5, 2008
  • 5 replies
  • 342 views
I have six thumbnails on a page and a large image. On clicking the thumbnail the thumbnail reloads the page with a URL variable 'photo' which then becomes the enlarged image source. All of that works perfectly at the moment.

However, the first time the page is loaded the URL variable 'photo' is not present so I'm trying to use IF/ELSE to automatically make it show 'photo 1' if URL variable 'photo' is not present.

Unfortunately I just can't make it work. The image source returns blank when no URL variable is present instead of defaulting to $row_rs_properties['photo1']

Can anyone suggest why this code doesn't work?

Dave
This topic has been closed for replies.

5 replies

Inspiring
September 5, 2008
Excellent. I was scratching my head for explanations if that had not been
the case! 8)

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"davecheet" <webforumsuser@macromedia.com> wrote in message
news:g9r8au$134$1@forums.macromedia.com...
> You were right though. I just reinstated my code but moved it to after the
> recordset and now it works like a swiss watch.
>
> Problem Solved.
>
> Thanks Murray
>
> Dave

davecheetAuthor
Inspiring
September 5, 2008
You were right though. I just reinstated my code but moved it to after the recordset and now it works like a swiss watch.

Problem Solved.

Thanks Murray

Dave
Inspiring
September 5, 2008
Let's see the whole thing, please.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:g9r5qb$rpn$1@forums.macromedia.com...
> $photo = isset($_GET['photo'])?$_GET['photo']:'photo1';
> $photo=($row_rs_properties[$photo]);
>
> Make sure that this comes AFTER the recordset.
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> ==================
>
>
> "davecheet" <webforumsuser@macromedia.com> wrote in message
> news:g9r2sb$os4$1@forums.macromedia.com...
>>I have six thumbnails on a page and a large image. On clicking the
>>thumbnail
>> the thumbnail reloads the page with a URL variable 'photo' which then
>> becomes
>> the enlarged image source. All of that works perfectly at the moment.
>>
>> However, the first time the page is loaded the URL variable 'photo' is
>> not
>> present so I'm trying to use IF/ELSE to automatically make it show 'photo
>> 1' if
>> URL variable 'photo' is not present.
>>
>> Unfortunately I just can't make it work. The image source returns blank
>> when
>> no URL variable is present instead of defaulting to
>> $row_rs_properties['photo1']
>>
>> Can anyone suggest why this code doesn't work?
>>
>> Dave
>>
>> <?php
>> //set photo variable if URL variable is present
>> if(isset($_GET['photo']))
>> {
>> $photo=($_GET['photo']);
>> }
>> // set photo variable to photo 1 if URL variable is not present
>> else{
>> $photo=($row_rs_properties['photo1']);
>> }
>> ?>
>>
>> //main image source uses $photo
>> <img src="images/propertyimages/<?php echo $photo; ?>"
>>
>

davecheetAuthor
Inspiring
September 5, 2008
Thanks Murray,

I pasted in your code after the recordset (and deleted my own) but still a blank result for the main image source. But now a blank return even when the URL variable is present.

Dave
Inspiring
September 5, 2008
$photo = isset($_GET['photo'])?$_GET['photo']:'photo1';
$photo=($row_rs_properties[$photo]);

Make sure that this comes AFTER the recordset.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"davecheet" <webforumsuser@macromedia.com> wrote in message
news:g9r2sb$os4$1@forums.macromedia.com...
>I have six thumbnails on a page and a large image. On clicking the
>thumbnail
> the thumbnail reloads the page with a URL variable 'photo' which then
> becomes
> the enlarged image source. All of that works perfectly at the moment.
>
> However, the first time the page is loaded the URL variable 'photo' is not
> present so I'm trying to use IF/ELSE to automatically make it show 'photo
> 1' if
> URL variable 'photo' is not present.
>
> Unfortunately I just can't make it work. The image source returns blank
> when
> no URL variable is present instead of defaulting to
> $row_rs_properties['photo1']
>
> Can anyone suggest why this code doesn't work?
>
> Dave
>
> <?php
> //set photo variable if URL variable is present
> if(isset($_GET['photo']))
> {
> $photo=($_GET['photo']);
> }
> // set photo variable to photo 1 if URL variable is not present
> else{
> $photo=($row_rs_properties['photo1']);
> }
> ?>
>
> //main image source uses $photo
> <img src="images/propertyimages/<?php echo $photo; ?>"
>