2015-04-06 64 views
0

特定字符串在我的PHTML即时通讯使用的foreach打印答案现在即时得到所有从数据库ANS但在具体ANS我想强调的是从数据库如何突出在Magento

<?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> 

获取数据在上面的代码中的IM回答。具体的答案意味着我要检查客户ID是相同或不若同比我想强调这个问题的答案如何做到这样的

Que: test 
    Ans: Ans1 (customerid = 1) 
     (highlight this Ans) Ans2 (customerid = 2) 
     Ans3(customerid = 3) 
使用这种支架(

O/P)仅仅是你可以理解

+0

你能在html中显示预期的结果吗?我没有清楚地理解你,所有外观你需要像这样:p class ='que-view-ans <?php if($ customer-> getId()== 555)echo'make-bold'; ?>'并为类'make-bold'创建css风格 – zhartaunik 2015-04-06 07:33:23

+0

你告诉我,如果条件在p标签中不可能,因为所有ans都有diff客户id。检查我的更新 – ND17 2015-04-06 07:41:35

+0

我仍然不完全明白这个问题。你在问如何突出显示标签'p'?或者你问关于突出显示的类型?或者您需要帮助来创建客户检查的条件? – zhartaunik 2015-04-06 07:49:51

回答

0

试试这个。

<p class='que-view-ans <?php if($a == $b) echo 'make-bold'; ?> '><?php echo '<b>' .$i .')</b>'.' '.$ans->getAnswers();?></p> 

不要忘记为'make-bold'类创建样式。

+0

感谢它的工作 – ND17 2015-04-06 08:26:08

+0

很高兴听到这个消息。祝你好运 – zhartaunik 2015-04-06 08:28:14