donglei_0507 2017-08-02 06:50
浏览 14
已采纳

打印一些数据而不是从数据库中提取的数据

I make one email function in that function i set the code of email template and also set the value which are i fetched from database.i upload one image in which the status field is 3 now i want to print confirmed instead of 3 in my email template.Here in the order array i get all the data.What i do to print Confirmed instead of 3.

public function setworkerTemplate($RESPONSE,$name)
    {
        $temp=$RESPONSE['temp'];
        $order=$RESPONSE['order'];
        $cust=$RESPONSE['cust'];
        $workers=$RESPONSE['workers'];
          echo "<pre>";
        print_r($order); 




            $logo=JURI::root()."images/logo-1.png";
                    $html ='<html>';
        $html.='<body>';
            $html.='<div style="width:100%;   background-color:#f6f6f6; border-top:#337ab7 5px solid; border-bottom:#337ab7 5px solid;">';
                $html.='<div style=" margin-left:15%;  margin-right:15%; ">';
                    $html.='<div style=" margin-top:5%;">';
                        $html.='<center><img src="'.$logo.'" style="width:200px; height:100px;"></center>';
                    $html.='</div>';
                    $html.='<div style=" margin-top:1%; color: #666; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: normal; line-height: 16px;">';
                        $html.='<b>Dear ,'.$workers['firstname'].'</b><br>';
                        $html.='<br>';                      
                        $html.='<b>Please find details about your schedule today for <a href="#">steamatichv.com</a> below.</b><br>';
                        $html.='<br>';
                        $html.='<table style="width:100%;" border="1" cellspacing="0" cellpadding="5"  bgcolor="#FFFFFF" bordercolor="#cccccc ">';
                            $html.='<tr  style=" box-shadow: 0px 0px 3px #888888;;">';
                                $html.='<td  style="padding-left: 5px;"><b>Order Number</b></td>';
                                $html.='<td style="padding-left: 5px;"><b>Schedule Date</b></td>';
                                $html.='<td style="padding-left: 5px;"><b>Schedule Time</b></td>';
                                $html.='<td style="padding-left: 5px;"><b>Status</b></td>';
                            $html.='</tr>';
                            $html.='<tr>';
                                $html.='<td>'.$order['Order_number'].'</td>';
                                $html.='<td>'.$order['schedule_date'].'</td>';
                                $html.='<td>'.$order['schedule_timeslot'].'</td>';
                                **[$html.='<td>'.$order\['published'\].'</td>';][1]**
                            $html.='</tr>';
                        $html.='</table><br>'; 
$html.='<div style=" margin-top:1%; color: #666; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: normal; line-height: 16px;">';
                        $html.='<p>Regards,<br>Steamatic HV Team</p>';      
                    $html.='</div>';
                $html.='</div>';  
            $html.='</div>';
        $html.='</body>';
    $html.='</html>';
     return $html; 

    }
  • 写回答

1条回答 默认 最新

  • dousi4900 2017-08-02 06:57
    关注

    You can use ternary operator.

    $html.='<td>'.($order['published'] == 3 ? 'Confirmed' : 'Unconfirmed').'</td>';
    

    If you have more than one case:

    $html .= '<td>';
    
    if($order['published'] == 1)
      $html .= 'Pending';
    else if($order['published'] == 2)
      $html .= 'Cancelled';
    else if($order['published'] == 3)
      $html .= 'Confirmed';
    else
      $html .= 'Unknown';
    
    $html .= '</td>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度