Changing Table Data Display

Posted on 2007-09-30
Last Modified: 2013-12-13

I have this table data in PHP:

echo ('<td class=' . $css_class . ' align=default >'.$val[1].'&nbsp</td>');

I want to change all "Y" results to "X" and all "N" results to blank.

Right now it displays like the one the left. I am trying to get it to display like the one on the right.

Y          X
Y          X
Y          X
Y          X

I believe something like the following would work, but I am not sure. Where would I add this into the <td> tags above?

== 'Y' ? 'X' : ''

Question by:fcruz5
    LVL 6

    Accepted Solution

    yeah, that would work.  if you changed: $val[1] to ($val[1] == 'Y' ? 'X' : '') it would change it
    however you need to be sure there will not be a third state you have not cinsidered

    Author Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    A colleague recently asked me about how to give his client a small part of the web site that could be completely under the client's control.  Since I have done this sort of thing before to add emergency banners to a web site, I decided I would creat…
    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now