在我的phtml中,我正在从数据库获取数据
<?php $id = $this->getRequest()->getParam('id');
$question = Mage::getModel('example/question')->load($id);
$answer = Mage::getModel('example/answer')->getCollection()->addFieldToFilter('id', $id);
$i = 1;
?>
<h2><?php echo $this->__('Your Question View')?></h2>
<div class="que-view">
<div><?php echo $this->__('<b>'.'Question:'.'</b>') . ' ' . $question->getQuestions();?></div>
<span class='que-view-tag'><?php echo $this->__('<b>'.'Answer'.'</b>'. ' ')?></span>
<?php foreach($answer as $ans):?>
<p class='que-view-ans'><?php echo '<b>' .$i .')</b>'.' '.$ans->getAnswers();?></p>
<?php $i++;?>
<?php endforeach;?>
</div>
在上面的代码中,我使用foreach打印答案,现在我从数据库中获取所有ans,但在特定的ans中,我想突出显示这个答案。具体的答案意味着我想检查客户id是否相同,如果相同,我想强调这个答案如何进行
O/p像这个
Que: test
Ans: Ans1 ( customerid = 1)
(highlight this Ans) Ans2 ( customerid = 2)
Ans3( customerid = 3)
使用这个括号()只是为了让你能理解
试试这个。
<p class='que-view-ans <?php if($a == $b) echo 'make-bold'; ?> '><?php echo '<b>' .$i .')</b>'.' '.$ans->getAnswers();?></p>
别忘了为"make bold"类创建样式。