Skip to main content
October 21, 2006
Question

PHP Yes/No or True/False Function

  • October 21, 2006
  • 4 replies
  • 672 views
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
This topic has been closed for replies.

4 replies

October 25, 2006
Thank you again David for all of your help on this project.

Thank you,
AdonaiEchad
October 22, 2006
Thank you so much, I really appreciate all your work, thank you both it has been most helpful.

AdonaiEchad
Inspiring
October 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/
Inspiring
October 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
>