PHP alternating cell colors vertically
<p>I am trying to show a table that shows different packages for membership and need to try to get each column to alternate colors to separate the packages. I have the code for alternating cells but they are doing them horizontal and not vertically. Please let me know if this is possible and where I have my code wrong to alternate the cells vertically. Thank you</p>

<pre><code>&lt;table width="100%" border="0" cellspacing="0"&gt;
    &lt;tr&gt;
        &lt;td&gt;&amp;nbsp;&lt;/td&gt;
            &lt;?php 
            foreach((array) $membership_names as $name) { ?&gt;
            &lt;td align="center" style="background:#ffffe4; padding:5px; border-top:1px solid #ccc; border-right:1px solid #fff; border-left:1px solid #fff;"&gt;&lt;strong&gt;&lt;?php echo $this-&gt;escape($name); ?&gt;&lt;/strong&gt;&lt;/td&gt;
            &lt;?php } ?&gt;
    &lt;/tr&gt;
            &lt;?php 
            $i = 1; // Our row counter
            foreach((array) $memberships as $membership) { 
                if ($i % 2 != 0) # An odd row
                    $rowStyle = "background:#FFFFE4; border-bottom:1px solid #ccc; border-top:1px solid #fff; height:40px; padding:10px;";
                else # An even row
                    $rowStyle = "background:#FFF4D8; border-bottom:1px solid #ccc; border-top:1px solid #fff; height:40px; padding:10px;";
                ?&gt;
    &lt;tr&gt;
        &lt;td align="left" style="&lt;?php echo $rowStyle; ?&gt;"&gt;&lt;strong&gt;&lt;?php echo $this-&gt;escape($membership['title']); ?&gt;:&lt;/strong&gt;&lt;/td&gt;
        &lt;?php foreach((array) $membership['values'] as $value) { 
                if ($i % 2 != 0) # An odd row
                    $rowStyle = "background:#FFFFE4; border-bottom:1px solid #ccc; border-top:1px solid #fff; height:40px; padding:10px;";
                else # An even row
                    $rowStyle = "background:#FFF4D8; border-bottom:1px solid #ccc; border-top:1px solid #fff; height:40px; padding:10px;";
                    ?&gt;
            &lt;td align="center" style="&lt;?php echo $rowStyle; ?&gt;"&gt;
                &lt;?php if($value == 'yes') { ?&gt;
                    &lt;img src="&lt;?php echo BASE_URL.TEMPLATE_PATH; ?&gt;images/icon_checkmark.gif" /&gt;
                &lt;?php } elseif($value == '-') {?&gt; 
                                            &lt;img src="&lt;?php echo BASE_URL.TEMPLATE_PATH; ?&gt;images/icon_checkno.gif" /&gt;
                                    &lt;?php } elseif($value == '0') {?&gt;
                                            &lt;img src="&lt;?php echo BASE_URL.TEMPLATE_PATH; ?&gt;images/icon_checkno.gif" /&gt;
                                    &lt;?php } else { ?&gt;
                    &lt;?php echo $this-&gt;escape($value); ?&gt;
                &lt;?php } ?&gt;
            &lt;/td&gt;
        &lt;?php } ?&gt;
        &lt;/tr&gt;

                    &lt;?php 
                    $i++; # Increment our row counter
                    } 
                    ?&gt;

                    &lt;tr&gt;
                    &lt;td align="left" valign="top" style="background:#9C6C69; color: #FFFFE4; border-bottom:1px solid #ccc; border-top:1px solid #fff; font-weight:bold; height:40px; padding:10px;"&gt;&amp;nbsp;&lt;/td&gt;
                    &lt;?php foreach((array) $pricing as $price) { ?&gt;
                            &lt;td align="center" valign="top" style="background:#9C6C69; border-bottom:1px solid #ccc; border-top:1px solid #fff; color: #FFFFE4; height:40px; padding:10px;"&gt;
                            &lt;?php foreach($price['pricing'] as $key=&gt;$value) { ?&gt;
                                    &lt;?php if(count($price['pricing']) &gt; 1) { ?&gt;&lt;p&gt;&lt;strong&gt;&lt;?php echo $lang['public_compare_option']; ?&gt; &lt;?php echo $key+1; ?&gt;&lt;/strong&gt;&lt;/p&gt;&lt;?php } ?&gt;
                                    &lt;?php if($value['label']) { ?&gt;
                                            &lt;p style="font-size:11px;"&gt;&lt;?php echo $this-&gt;escape($value['label']); ?&gt;&lt;/p&gt;
                                    &lt;?php } else { ?&gt;
                                            &lt;?php //echo $lang['public_compare_term']; ?&gt;
                                            &lt;?php if($value['period_count']) { ?&gt;
                                                     &lt;p style="font-size:11px; font-weight:bold;"&gt;&lt;?php echo $this-&gt;escape($value['period_count']); ?&gt; &lt;?php echo $this-&gt;escape($value['period']); ?&gt;&lt;/p&gt;
                                            &lt;?php } else { ?&gt;
                                                    &lt;p&gt;&lt;?php echo $lang['public_compare_lifetime']; ?&gt;&lt;/p&gt;
                                            &lt;?php } ?&gt;
                                            &lt;?php if($value['setup_price'] != '0.00') { ?&gt; 
                                                    &lt;p&gt;&lt;?php echo $lang['public_compare_setup']; ?&gt;: &lt;?php echo $this-&gt;escape(format_number_currency($value['setup_price'])); ?&gt;&lt;/p&gt; 
                                            &lt;?php } ?&gt;
                                            &lt;?php //echo $lang['public_compare_price']; ?&gt;
                                            &lt;?php if($value['price'] != '0.00') { ?&gt;
                                                    &lt;p style="border-bottom: 1px dashed #FFFFFF; border-top: 1px dashed #FFFFFF; font-size: 14px; font-weight: bold; margin-top: 2px; padding: 2px;"&gt;$&lt;?php echo $this-&gt;escape($value['price']); ?&gt;&lt;/p&gt;
                                            &lt;?php } else { ?&gt;
                                                    &lt;p style="border-bottom: 1px dashed #FFFFFF; border-top: 1px dashed #FFFFFF; font-size: 14px; font-weight: bold; margin-top: 2px; padding: 2px;"&gt;&lt;?php echo $lang['public_compare_free']; ?&gt;&lt;/p&gt;
                                            &lt;?php } ?&gt;
                                    &lt;?php } ?&gt;
                                    &lt;p&gt;&lt;a href="&lt;?php echo BASE_URL.MEMBERS_FOLDER; ?&gt;user_orders_add_listing.php?pricing_id=&lt;?php echo $value['id']; ?&gt;" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" style="margin-top:3px;padding:5px;"&gt;&lt;?php echo $lang['public_compare_order']; ?&gt;&lt;/a&gt;&lt;/p&gt;
                            &lt;?php } ?&gt;
                            &lt;/td&gt;
                    &lt;?php } ?&gt;
                    &lt;/tr&gt;

                &lt;/table&gt;
</code></pre>
