My controller function:
function index()
{
$data['user_clicks'] = $this->common_model->get_userClicks();
$this->load->view('common/header');
$this->load->view('content_pages/user_clicks',$data);
$this->load->view('common/footer');
}
My model
function get_userClicks()
{
$this->db->select('agent_id,click_type,click_count');
$this->db->select_sum('click_count');
$this->db->from('daily_clicks');
$this->db->group_by('click_type,agent_id');
$this->db->order_by('agent_id');
$q = $this->db->get();
return $q->result_array();
}
this is i am getting, what i want is to get the click_count of phone click, email click,offline click with respect to their columns and their total clicks is already done. the data base image is the last one klindly help me get through it. Thank you
Try this,
$resarr=count($resultarray);
<table>
<tr>
<th>Agent_id</th>
<th>phone_click</th>
<th>email_click</th>
<th>offline_click</th>
<th>total_click</th>
</tr>
for($i=1; $i<100; $i++){ //agent id
for($j=1; $j<=$resarr; $j++) //number of records
{
echo "<tr>";
if($arr['user_clicks'][$j]['agent_id'] == $i)
{
if(!empty($arr['user_clicks'][$j]['agent_id']){
echo "<td">
echo $arr['user_clicks'][$j]['agent_id'];
echo "</td>";
}
if($arr['user_clicks'][$j]['click_type']=='phone'){
echo "<td">
echo $arr['user_clicks'][$j]['click_type'];
echo "</td>";
}
else
{
echo "<td">
echo '';
echo "</td>";
}
if($arr['user_clicks'][$j]['click_type']=='email'){
echo "<td">
echo $arr['user_clicks'][$j]['click_type'];
echo "</td>";
}else
{
echo "<td">
echo '';
echo "</td>";
}
if($arr['user_clicks'][$j]['click_type']=='offline'){
echo "<td">
echo $arr['user_clicks'][$j]['click_type'];
echo "</td>";
}
else
{
echo "<td">
echo '';
echo "</td>";
}
if(!empty($arr['user_clicks'][$j]['click_count']){
echo "<td">
echo $arr['user_clicks'][$j]['click_count'];
echo "</td>";
}
else
{
echo "<td">
echo '';
echo "</td>";
}
}
echo "</tr>";
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.