php后台模板html拼接写法

时间:2022-12-01 15:41:05
 public function get_kefu_reply_list(){
         $wid=$this->_post('order_id');
         if(!$wid){
             echo('工单信息获取失败!');
             exit;
         }
         $where=null;
         $where['A.wid']=$wid;
         $list=M('kefu_reply')->alias("A")->join('z_user_common as  B on  A.uid=B.id')->
         where($where)->field('A.*,B.realname,B.account')->order('A.do_time desc')->select();
         foreach ($list as $key => $value) {
             if(mb_strlen($value['content'])>15){
                 $list[$key]['content_new']=mb_substr($value['content'],0,6,'utf-8');
             }else{
                  $list[$key]['content_new']=$value['content'];
             }
             $list[$key]['dotime']=date("Y-m-d H:i:s", $value['do_time']);
         }
         if($list){
             $str="";
             $str.="<table align='center' border='1' width='500' cellpadding='1' cellspacing='1'>";
             $str.="<tr>";
             $str.="<td align='center'>跟进人名称</td>";
             $str.="<td align='center'>跟进人账号</td>";
             $str.="<td align='center'>跟进内容</td>";
             $str.="<td align='center'>跟进时间</td>";
             $str.="</tr>";
             foreach($list as $k=>$v){
                 $str.="<tr>";
                 $str.="<td align='center'>$v[realname]</td>";
                 $str.="<td align='center'>$v[account]</td>";
                 $str.="<td align='center'>";
                 $str.="<a href='javascript:void(0);' a='$v[content]' onclick='get_detail_contents(this);' style='color:blue;'>$v[content_new]...</a>";
                 $str.="</td>";
                 $str.="<td align='center'>$v[dotime]</td>";
                 $str.="</tr>";
             }
             $str.='</table>';
             echo $str;
         }else{
             echo 0; //暂无数据
         }
     }