【发布时间】:2019-11-26 07:29:57
【问题描述】:
我正在尝试使用 Json_encode 将 $data 从控制器传输到视图。在 For 循环中面临问题,我无法使用 HTML 格式正确嵌入(“'..'”)它。请帮我解决这个问题。
谢谢! :)
$data ='
<div class="col-lg-12">
<div class="ibox">
<div class="ibox-title">
<h5>Leave Table </h5>
</div>
<div class="ibox-content">
<table class="table table-bordered" id="changeBlock">
<thead>
<tr>
<th>Agents</th>
'. for($i = 1; $i <= $days; $i++){
echo "<th class='w-30'>'.$i.'</th>";
} .'
</tr>
</thead>
<tbody>
'.$cnt = count($agent_list); if(isset($agent_list) && ($agent_list != '')){ foreach($agent_list as $val) { $agent_id = $val['info']->ps_crm_agent_id;
for($i = $cnt; $i <= $cnt ; $i++){
echo '<tr><td data-id="'.$agent_id.'">'.$val['info']->firstname.' '.$val['info']->lastname.'</td>';
for($j = 1; $j <= $days; $j++){
if(!empty($val['leaves'])){
$key = array_search($j, array_column($val['leaves'], 'leave_date'));
if(is_numeric($key)){
echo '<td class="cell_style w-30 pointer" data-id-leaves= '.$val['leaves'][$key]['id_leaves'].' data-id='.$agent_id.' data-date="'.$j.'" style="background-color: '.$val['leaves'][$key]['color_code'].'"> </td>';
}else{
echo '<td class="cell_style w-30 pointer" data-id-leaves="0" data-id='.$agent_id.' data-date="'.$j.'"> </td>';
}
}else{
echo '<td class="cell_style w-30 pointer" data-id-leaves="0" data-id='.$agent_id.' data-date="'.$j.'"> </td>';
}
}
echo '</tr>';
} } }'
</tbody>
</table>
</div>
</div>
</div>';
$data = $this->load->view('load_leave_calender', $data, TRUE);
** 在**面临问题
'. for($i = 1; $i <= $days; $i++){
echo "<th class='w-30'>'.$i.'</th>";
} .'
【问题讨论】:
标签: php json codeigniter