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

Convert 'Dynamic Text' with "1/0" to "Yes/No"

Explorer ,
Sep 22, 2011 Sep 22, 2011

Hi, I have a search-results page that returns a number of fields as 1 or 0 (information collected from tick-boxes in my original submission form).

I have added a dynamic field in my results form to display these results, but they (obviously) come back as 1 or 0. How do I get this to render as "Yes" or "No"?

TOPICS
Server side applications
714
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

Mentor , Sep 22, 2011 Sep 22, 2011

If you are using PHP:

if ($fieldname1==1){

$fieldname1='Yes';

} else {

$fieldname1='No';}

echo $fieldname1;

Translate
Mentor ,
Sep 22, 2011 Sep 22, 2011

If you are using PHP:

if ($fieldname1==1){

$fieldname1='Yes';

} else {

$fieldname1='No';}

echo $fieldname1;

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 ,
Sep 25, 2011 Sep 25, 2011

I usually do things like that with a ternary operator -

($fieldname==0)?$fieldname = "No":$fieldname = "Yes";

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 ,
Sep 25, 2011 Sep 25, 2011
LATEST

Or, of course, if you want to leave the data as 0 and 1, then this -

echo ($fieldname==0)?"No":"Yes";

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