0
PHP IF/ELSE
Participant
,
/t5/dreamweaver-discussions/php-if-else/td-p/93745
Sep 05, 2008
Sep 05, 2008
Copy link to clipboard
Copied
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
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
TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/php-if-else/m-p/93746#M135261
Sep 05, 2008
Sep 05, 2008
Copy link to clipboard
Copied
$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; ?>"
>
$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; ?>"
>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
davecheet
AUTHOR
Participant
,
/t5/dreamweaver-discussions/php-if-else/m-p/93747#M135262
Sep 05, 2008
Sep 05, 2008
Copy link to clipboard
Copied
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
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/php-if-else/m-p/93748#M135263
Sep 05, 2008
Sep 05, 2008
Copy link to clipboard
Copied
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; ?>"
>>
>
--
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; ?>"
>>
>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
davecheet
AUTHOR
Participant
,
/t5/dreamweaver-discussions/php-if-else/m-p/93749#M135264
Sep 05, 2008
Sep 05, 2008
Copy link to clipboard
Copied
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
Problem Solved.
Thanks Murray
Dave
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
LATEST
/t5/dreamweaver-discussions/php-if-else/m-p/93750#M135265
Sep 05, 2008
Sep 05, 2008
Copy link to clipboard
Copied
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
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

