fubarur Posted June 14, 2010 Share Posted June 14, 2010 Ok this one is driving me crazy... I have product categories and I want a little snipet of html to be displayed if someone looks a one certain category category is 79000 <?php // Scratch & Dent echo $product['sub_category_id']; if ($product['sub_category_id'] == 79000); ?> <tr><td colspan="2" class="font-smx"><?=display_cms_data(160)?></td><tr> <?php else: ?> What happens is that no matter what category that is viewed this html gets displayed. I have added the echo line when I was having issues to make sure that I had it pulling from correct area. When I view the 79000 category I see the correct echo number and get the html displayed, but when viewing another category (lets say 36800) echo line says 36800 and html is still displayed. What am I doing wrong? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/204763-help-with-an-if-statement-please/ Share on other sites More sharing options...
kenrbnsn Posted June 14, 2010 Share Posted June 14, 2010 Remove the ";" from the end of you "if" statement Ken Quote Link to comment https://forums.phpfreaks.com/topic/204763-help-with-an-if-statement-please/#findComment-1072000 Share on other sites More sharing options...
fubarur Posted June 14, 2010 Author Share Posted June 14, 2010 Thanks Ken I tried <?php // Scratch & Dent if ($product['sub_category_id'] == 79000) ?> <tr><td colspan="2" class="font-smx"><?=display_cms_data(160)?></td><tr> <?php else: ?> No change, any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/204763-help-with-an-if-statement-please/#findComment-1072004 Share on other sites More sharing options...
Alex Posted June 14, 2010 Share Posted June 14, 2010 You need a colon there. See the manual on alternative syntax. Quote Link to comment https://forums.phpfreaks.com/topic/204763-help-with-an-if-statement-please/#findComment-1072006 Share on other sites More sharing options...
fubarur Posted June 14, 2010 Author Share Posted June 14, 2010 colon gives me a white page Quote Link to comment https://forums.phpfreaks.com/topic/204763-help-with-an-if-statement-please/#findComment-1072012 Share on other sites More sharing options...
kenrbnsn Posted June 14, 2010 Share Posted June 14, 2010 Change it to <?php // Scratch & Dent if ($product['sub_category_id'] == 79000) { echo '<tr><td colspan="2" class="font-smx">' . display_cms_data(160) . '</td><tr>'; } ?> You don't need an "else" clause if there's nothing to do. Ken Quote Link to comment https://forums.phpfreaks.com/topic/204763-help-with-an-if-statement-please/#findComment-1072014 Share on other sites More sharing options...
fubarur Posted June 14, 2010 Author Share Posted June 14, 2010 Ken, you are my savior! This is why this site rocks! thanks again!! Quote Link to comment https://forums.phpfreaks.com/topic/204763-help-with-an-if-statement-please/#findComment-1072016 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.