Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Displaying and translating codes

Explorer ,
Mar 30, 2008 Mar 30, 2008
Here is an easy question for someone. I am storing code values ("Y", "N"), in a Mysql database column and when I display the field in Dreamweaver, I would like to have it appear as "Yes", or "No", not just the letter, as the case warrants. The only way I see doing this is with a menu or list but that builds a select drop down list box and I want display only, no entry. Surely there is an easy way to do this that is simply eluding me.

Any thoughts??
TOPICS
Server side applications
635
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 30, 2008 Mar 30, 2008
Murray *ACE* wrote:
> <?php echo (fieldvalue) == 'Y'?'Yes":"No"; ?>

You've got your quotes badly mixed up.

<?php echo (fieldvalue) == 'Y'?'Yes':'No'; ?>

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
LEGEND ,
Mar 30, 2008 Mar 30, 2008
<?php echo (fieldvalue) == 'Y'?'Yes":"No"; ?>

--
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
==================


"DreamerJim" <webforumsuser@macromedia.com> wrote in message
news:fsopk9$knv$1@forums.macromedia.com...
> Here is an easy question for someone. I am storing code values ("Y",
> "N"), in
> a Mysql database column and when I display the field in Dreamweaver, I
> would
> like to have it appear as "Yes", or "No", not just the letter, as the case
> warrants. The only way I see doing this is with a menu or list but that
> builds
> a select drop down list box and I want display only, no entry. Surely
> there is
> an easy way to do this that is simply eluding me.
>
> Any thoughts??
>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 30, 2008 Mar 30, 2008
Murray *ACE* wrote:
> <?php echo (fieldvalue) == 'Y'?'Yes":"No"; ?>

You've got your quotes badly mixed up.

<?php echo (fieldvalue) == 'Y'?'Yes':'No'; ?>

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 30, 2008 Mar 30, 2008
Thanks. Not so bad - only one was improperly noted. Out of the 6 in that
snippet, that's only a 16% deduction. Nevermind that it breaks everything.

--
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
==================


"David Powers" <david@example.com> wrote in message
news:fsp09r$rj6$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> <?php echo (fieldvalue) == 'Y'?'Yes":"No"; ?>
>
> You've got your quotes badly mixed up.
>
> <?php echo (fieldvalue) == 'Y'?'Yes':'No'; ?>
>
> --
> David Powers, Adobe Community Expert
> Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 31, 2008 Mar 31, 2008
.oO(DreamerJim)

>Here is an easy question for someone. I am storing code values ("Y", "N"), in
>a Mysql database column and when I display the field in Dreamweaver, I would
>like to have it appear as "Yes", or "No", not just the letter, as the case
>warrants. The only way I see doing this is with a menu or list but that builds
>a select drop down list box and I want display only, no entry. Surely there is
>an easy way to do this that is simply eluding me.

Besides the given PHP solution, you could also let the database do it:

SELECT
CASE yourField = 'Y'
THEN 'Yes'
ELSE 'No'
END AS choice,
...
FROM yourTable
WHERE ...

Micha
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 31, 2008 Mar 31, 2008
Micha:

That is an interesting alternative.

> SELECT
> CASE yourField = 'Y'
> THEN 'Yes'
> ELSE 'No'
> END AS choice,

is 'choice' the returned variable that would contain the values of "Yes" or
"No"?

--
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
==================


"Michael Fesser" <netizen@gmx.de> wrote in message
news:gji1v3hpequ4i525osthr4ek0ua2klq10h@4ax.com...
> .oO(DreamerJim)
>
>>Here is an easy question for someone. I am storing code values ("Y",
>>"N"), in
>>a Mysql database column and when I display the field in Dreamweaver, I
>>would
>>like to have it appear as "Yes", or "No", not just the letter, as the case
>>warrants. The only way I see doing this is with a menu or list but that
>>builds
>>a select drop down list box and I want display only, no entry. Surely
>>there is
>>an easy way to do this that is simply eluding me.
>
> Besides the given PHP solution, you could also let the database do it:
>
> SELECT
> CASE yourField = 'Y'
> THEN 'Yes'
> ELSE 'No'
> END AS choice,
> ...
> FROM yourTable
> WHERE ...
>
> Micha

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 31, 2008 Mar 31, 2008
.oO(Murray *ACE*)

>That is an interesting alternative.
>
>> SELECT
>> CASE yourField = 'Y'
>> THEN 'Yes'
>> ELSE 'No'
>> END AS choice,
>
>is 'choice' the returned variable that would contain the values of "Yes" or
>"No"?

Yes, it's an alias name. If you use such statements in the SELECT you
should always give them an alias name (AS ...), otherwise the entire
statement would become the name of that field in the result set.

The CASE statement is a very powerful construct, not only in SELECTs.
It can also be used in an ORDER BY clause for example to create very
sophisticated sorting rules.

Micha
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 31, 2008 Mar 31, 2008
Thanks, Micha. I am looking into the use of this....

--
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
==================


"Michael Fesser" <netizen@gmx.de> wrote in message
news:h7q1v3lcb9i0qh7qirb523kd90uds7mrk9@4ax.com...
> .oO(Murray *ACE*)
>
>>That is an interesting alternative.
>>
>>> SELECT
>>> CASE yourField = 'Y'
>>> THEN 'Yes'
>>> ELSE 'No'
>>> END AS choice,
>>
>>is 'choice' the returned variable that would contain the values of "Yes"
>>or
>>"No"?
>
> Yes, it's an alias name. If you use such statements in the SELECT you
> should always give them an alias name (AS ...), otherwise the entire
> statement would become the name of that field in the result set.
>
> The CASE statement is a very powerful construct, not only in SELECTs.
> It can also be used in an ORDER BY clause for example to create very
> sophisticated sorting rules.
>
> Micha

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 31, 2008 Mar 31, 2008
.oO(Michael Fesser)

>SELECT
> CASE yourField = 'Y'
> THEN 'Yes'
> ELSE 'No'
> END AS choice,
> ...

Little syntax error - it should be

SELECT
CASE WHEN yourField = 'Y'
THEN 'Yes'
ELSE 'No'
END AS choice,
...

Micha
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 04, 2008 Apr 04, 2008
LATEST
Where would this be placed within the standard SELECT clause? e.g.,
SELECT * from custtable
WHERE custid=varname;
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 31, 2008 Mar 31, 2008
Murray *ACE* wrote:
> Thanks, Micha. I am looking into the use of this....
>

Its well worth it Murray, I now use them all the time, its really powerful.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 31, 2008 Mar 31, 2008
Seems that way - especially with Micha's correction! 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
==================


"Dooza" <doozadooza@gmail.com> wrote in message
news:fsqrq1$38s$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> Thanks, Micha. I am looking into the use of this....
>>
>
> Its well worth it Murray, I now use them all the time, its really
> powerful.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines