Jump to content

help with an if statement, please


fubarur

Recommended Posts

Ok this one is driving me crazy...  :shrug:

 

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.

 

 

Link to comment
https://forums.phpfreaks.com/topic/204763-help-with-an-if-statement-please/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.