Coloring rows in returned drupal search results I'm trying to modify search-result.tpl.php and template.php to color the backgrounds of search results returned such that every row has a different color than the one that preceded it. Only two colors are used. so, row #1 returned would have background #eee and row 2 would have #ff0000 as its background color. It would start over again at row #3 having #eee and so on. This is easily enough accomplished with PHP. But how can I implement this with Drupal?

Here's how I'm trying to print it out in search-result.tpl.php:

&lt;li class="&lt;?php print $classes; ?&gt;"&lt;?php print $attributes; ?&gt;&gt;
  &lt;div class="search-snippet-info"&gt;
    &lt;?php $inc=0; ?&gt;
      &lt;?php if ($inc %2 == 0) {
                $color = '#eee';
              } else {  
                $color = '#ff0000';
              }
              ?&gt;
      &lt;div style="background-color: &lt;?php print $color ?&gt;"&gt;
      &lt;div class="icon" style="float:left;"&gt;&lt;?php print render($teaser['field_icon']); ?&gt;&lt;/div&gt;
      &lt;div class="teaser"&gt;
      &lt;header&gt;
      &lt;h2&gt;&lt;a href="&lt;?php print $result['link']; ?&gt;"&gt;&lt;?php print $result['title']; ?&gt;&lt;/a&gt;&lt;/h2&gt;
      &lt;/header&gt;
      &lt;em&gt;&lt;?php print render($teaser['field_type']); ?&gt;&lt;/em&gt;
      &lt;strong&gt;&lt;?php print render($teaser['field_event_dates']); ?&gt;&lt;/strong&gt;
      &lt;?php print render($teaser['body']); ?&gt;
      &lt;/div&gt;
      &lt;?php $inc++; ?&gt;
      &lt;/div&gt;
  &lt;/div&gt;
&lt;/li&gt;


Not getting errors, but the results are not what I was expecting. Each row is just returning the same color background #eee, the first color). So either the $inc variable is not getting incremented or (perhaps more likely) it's becoming '0' again after every returned result. So then I'm thinking maybe I need to add something to my preprocess_search_result function in my template.php file...but I don't know what to add there.

Any help would be greatly appreciated.
I would create your search results page using views, this has the odd/even class functionality built-in. The current code you provided won't work since the $inc value starts as 0 and there is no loop where $inc++ occurs so everytime this template is loaded $inc will start as 0 and end as 1.