Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jul 2007
    Posts
    62
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Changing Table Data Display

    Hi,

    I have a several columns on an auto generated report.

    On one column, the data that it displays is either "Y" or "N". Is there a way to make all the "Y"s display as an "X" and all the "N"s just display blank?

    If so, how would I create something like that?

    Any help is appreciated. Thanks!

    ============================

    Sara

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    You would have to show us your code, or at least part of it for any specific help, but this could be easily accomplished with an if switch or ternary.
    ex.
    PHP Code:
    $output '';
    if(
    $string == 'Y')
    {
        
    $output 'X';
    }

    // or
    $output = ($string == 'Y' 'X' ''); 
    Last edited by Inigoesdr; 08-17-2007 at 11:25 PM. Reason: Typo

  • #3
    New Coder
    Join Date
    Jul 2007
    Posts
    62
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Hi,

    Thanks for the reply. Here is the code:

    Code:
    <table  border="0" cellpadding="4" cellspacing="1" bgcolor="#fff">
    <tr>
    <td class="one" >COL 1</td>
    <td class="one" >COL 2</td>
    <td class="one" >COL 3</td>

    </tr>

    PHP Code:
    <?php
    $rowcount 
    0;
    $group1_current_row 0;
    $group2_current_row 0;
    $group3_current_row 0;
    $grouptotal_current_row 0;
    $isStart01 0;
    $isStart02 0;
    $isStart03 0;

    while (
    $row mysql_fetch_array($result)) {

      if (
    $rowcount == 0) {
      }
      
    $newgroupindex = -1;
        echo 
    "<tr>";
        if ((
    $rowcount%2) == 0) {
            
    $css_class "\"other\"";
        } else {
            
    $css_class "\"altrow\"";
        }
        
    $cellvalue "" $row[0] . "";
        if (
    $cellvalue == "") {
            
    $cellvalue "&nbsp;";
        }
        echo 
    "<td class=" $css_class "   align=Default >" $cellvalue "</td>";
        
    $cellvalue "" $row[1] . ""//this is the one that displays either a "Y" or "N"
        
    if ($cellvalue == "") {
            
    $cellvalue "&nbsp;";
        }
        echo 
    "<td class=" $css_class "   align=Default >" $cellvalue "</td>";
        
    $cellvalue "" $row[2] . "";
        if (
    $cellvalue == "") {
            
    $cellvalue "&nbsp;";
        }
        
    $newgroupindex = -1;
      
    $rowcount $rowcount 1;
        
    $isStart01++;
        
    $isStart02++;
        
    $isStart03++;
        
    $isStart04++;
        
    $isStart05++;
        echo 
    "</tr>";
    }

    ?>
    Code:
    </table>

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Try this:
    PHP Code:
    $cellvalue = ($row[1] == 'Y' 'X' '');
    /*
    $cellvalue = "" . $row[1] . ""; //this is the one that displays either a "Y" or "N" 
    if ($cellvalue == "") {
            $cellvalue = "&nbsp;";
        }*/ 
    You can remove the commented part if it works.
    Last edited by Inigoesdr; 08-18-2007 at 12:41 AM.

  • #5
    New Coder
    Join Date
    Jul 2007
    Posts
    62
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Hi,

    I tried it, but I get the following error on that line:

    Parse error: syntax error, unexpected ';'

    Sara

  • #6
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    I forgot to close the parenthesis.

    I edited the code in my previous post, try it and let me know. =]

  • #7
    New Coder
    Join Date
    Jul 2007
    Posts
    62
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Hi,

    Not a problem. Thanks for all of your help! It works great now.

    Sara


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •