Covert a number returned from MYSQL to a text sentance.

I have a line on my website that returns a yes or no option using 1 for YES and 0 for NO in the MYSQL Database.

I would like to try and convert the numbers, that currently are displayed on the page, to text. YES for 1 or NO for ) are displayed instead of the numbers.

Simple put I want to convert a 0 to show NO and a 1 to show YES.

Ay help would be appreciated.

use str_replace for that:

[php]
if($somevar == 0){ $somevar =‘No’;}
if($somevar == 1){ $somevar =‘Yes’;}
[/php]

Bang on my friend, thanks a bunch.

0 will return boolean false so you could simply do:

[php]
$myVar = 0;
echo ($myVar ? “Yes” : “No”);
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service