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

PHP Yes/No or True/False Function

Guest
Oct 21, 2006 Oct 21, 2006
I have a dynamic table that shows the fowllowing...

<td><?php echo $row_rsAnnouncement['online']; ?></td>

I am using MySQL database, and it is "tinyint".

When I view it, it shows either 0 or 1. How can I make this online field to say Yes or No. If that is not possible even if it is shows a True or False I can be happy with that.

I know that in Coldfusion there is a function called #YesNoFormat()#, is there one for PHP?

Thank you,
AdonaiEchad
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
LEGEND ,
Oct 21, 2006 Oct 21, 2006
<td><?php echo ($row_rsAnnouncement['online']=="1"?'Yes':'No'); ?></td>

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"AdonaiEchad" <webforumsuser@macromedia.com> wrote in message
news:ehe5gv$koi$1@forums.macromedia.com...
>I have a dynamic table that shows the fowllowing...
>
> <td><?php echo $row_rsAnnouncement['online']; ?></td>
>
> When I view it, it shows either 0 or 1. How can I make this online field
> to
> say Yes or No. If that is not possible even if it is shows a True or
> False I
> can be happy with that.
>
> I know that in Coldfusion there is a function called #YesNoFormat()#, is
> there
> one for PHP?
>
> Thank you,
> AdonaiEchad
>


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 ,
Oct 21, 2006 Oct 21, 2006
Murray *ACE* wrote:
> <td><?php echo ($row_rsAnnouncement['online']=="1"?'Yes':'No'); ?></td>

Even simpler:

<td><?php echo $row_rsAnnouncement['online'] ? 'Yes' : 'No'; ?></td>

If a variable contains 0, it's an implicit Boolean false. Any other
number (or string) is an implicit Boolean true.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (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
Guest
Oct 21, 2006 Oct 21, 2006
Thank you so much, I really appreciate all your work, thank you both it has been most helpful.

AdonaiEchad
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
Guest
Oct 24, 2006 Oct 24, 2006
LATEST
Thank you again David for all of your help on this project.

Thank you,
AdonaiEchad
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