Jump to content

Check SQL database for Value, If Statement


NAmeviolated

Recommended Posts

 

Sorry going to be a big post, but trying to query a sql database for a value

 

Original code

 

<?php if($this->item->params->get('catItemExtraFields') && count($this->item->extra_fields)): ?>

  <!-- Item extra fields -->

  <div class="catItemExtraFields">

  <h4><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h4>

  <ul>

<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>

<?php if($extraField->value): ?>

<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">

<span class="catItemExtraFieldsLabel"><?php echo $extraField->name; ?></span>

<span class="catItemExtraFieldsValue"><?php echo $extraField->value; ?></span>

</li>

<?php endif; ?>

<?php endforeach; ?>

</ul>

    <div class="clr"></div>

  </div>

  <?php endif; ?>

 

 

Now I want to check the name field for a value and if it is Closing Date print out something different from the value in value, so I've changed the red code to

 

<span class="catItemExtraFieldsLabel"><?php if $extraField->name ="Closing date"; ?></span>

{

<span class="catItemExtraFieldsLabel"><?php echo $extraField->name; ?></span>

    <span class="catItemExtraFieldsValue"><?php echo $this->item->publish_down, JText::_('K2_DATE_FORMAT_LC2')); ?></span>

                }

                else

                {

                <span class="catItemExtraFieldsLabel"><?php echo $extraField->name; ?></span>

<span class="catItemExtraFieldsValue"><?php echo $extraField->value; ?></span>

                }

<?php endif; ?>

 

Doesn't work though, tried a heap of variations but can't figure it out.

 

Thanks

 

Marc

 

 

Link to comment
Share on other sites

ahh the good old K2. Working with that as well! Good stuff!

 

I think you are misinterpreting the way K2 is coded.

 

It should be this:

 

<span class="catItemExtraFieldsLabel"><?php if ($extraField->name ="Closing date") : ?></span>

            <span class="catItemExtraFieldsLabel"><?php echo $extraField->name; ?></span>
             <span class="catItemExtraFieldsValue"><?php echo $this->item->publish_down,JText::_('K2_DATE_FORMAT_LC2')); ?></span>
		<?php else :?>
                <span class="catItemExtraFieldsLabel"><?php echo $extraField->name; ?></span>
            <span class="catItemExtraFieldsValue"><?php echo $extraField->value; ?></span>

            <?php endif; ?>

 

But you are doing something wrong where you try to echo the publish_down and the date... What is it that you are trying to do?

Link to comment
Share on other sites

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.