Views PHP: Comparing two Field and display Answer I tried to build a soccer magazine website. I want to display Match Win/Loss/Draw in the Match Result Page with the score result. I want to display it like:

if [field_score1] > [field_score2] display 'Win'
if [field_score1] &lt; [field_score2] display 'Loss'
if [field_score1] = [field_score2] display 'Draw'

Im stuck please Help.
First,  In your Match Results view, add a Global: Custom text field and just leave it blank/empty. (we will use this field to print the outcome)

You can override the view's display through your themes template file.

Go to sites/all/themes/YOURTHEME/  look for template.php and open it. You probably have other code inside there, so make extra space by hitting enter at the bottom and add the following code.

function YOURTHEME_preprocess_views_view_fields($vars){


      if ($vars['view']-&gt;name == "VIEWNAME" &amp;&amp; $vars['view']-&gt;current_display == "DISPLAY" &amp;&amp; $vars['fields']['field_score1']-&gt;raw &gt; $vars['fields']['field_score2']-&gt;raw){
        $vars['fields']['nothing']-&gt;content = print 'Win';
      }

      else if ($vars['view']-&gt;name == "VIEWNAME" &amp;&amp; $vars['view']-&gt;current_display == "DISPLAY" &amp;&amp; $vars['fields']['field_score1']-&gt;raw &lt; $vars['fields']['field_score2']-&gt;raw){
        $vars['fields']['nothing']-&gt;content = print 'Loss';
      }

      else if ($vars['view']-&gt;name == "VIEWNAME" &amp;&amp; $vars['view']-&gt;current_display == "DISPLAY" &amp;&amp; $vars['fields']['field_score1']-&gt;raw == $vars['fields']['field_score2']-&gt;raw){
        $vars['fields']['nothing']-&gt;content = print 'Draw';
      }

}


Replace YOURTHEME with your actual theme name

Replace VIEWNAME with your view machine name. (example: match_results)

Replace DISPLAY with your display machine name. (example: block, block_1 ) You can find the name by looking at your view. (see picture below). If you're using the Master view, then the machine name is "default"

.jpg