2016-07-22 40 views
0

控制器阵列到字符串转换错误在笨2.x的

public function livefeed($data = NULL) { 


    //echo $this->uri->segment(3);exit; 
    $this->load->model("home_model"); 

    $config = array(); 
    $config["base_url"] = base_url("content/livefeed/"); 
    $config["total_rows"] = $this->home_model->record_count(); 
    $config["per_page"] = 10; 
    $config["uri_segment"] = 3; 

    $config['num_links'] = 2; 
    $config['use_page_numbers'] = TRUE; 
    $config['page_query_string'] = TRUE; 

    $config['full_tag_open'] = '<p>'; 
    $config['full_tag_close'] = '</p>'; 

    $this->pagination->initialize($config); 
    $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0; 

    $data["results"] = $this->home_model->getLiveFeed($config["per_page"], $page); 
    $data["links"] = $this->pagination->create_links(); 

    $this->load->view("live", $data); 


} 

模型

public function getLiveFeed($limit = NULL, $start = NULL) { 

    $this->db->select('*'); 
    $this->db->where('status', 1); 
    $this->db->from('rs_tbl_live'); 
    $this->db->limit($limit, $start); 
    $query = $this->db->get(); 

    if($query->num_rows() > 0) { 

     foreach ($query->result() as $row) { 
      $data[] = $row; 
     } 

     return $data;; 
    } 
    return false; 
} 

查看

遇到

甲PHP错误

严重性:注意

消息:Array对字符串的转换

文件名:控制器/ content.php

行号:64

foreach($results as $rowTV){ 
    <div class="unit item movie-item pull-left" data-key="<?=$rowTV->id;?>"><a href="" class="ChannelCov"> <img src='<?=IMAGE_PATH.$rowTV->img;?>' width="100%" 
    alt="#LifeIsMusic <?=$rowTV->name;?>" title="<?=$rowTV->name;?>" /> </a> 
     <h2> <a href=""> <?=$rowTV->name;?> </a> </h2> 
    </div> 

    } 
+0

在第一页上可以看到分页。当我试图调用或点击第二或下一个按钮此错误显示 **遇到 甲PHP错误 严重性:注意 消息:Array对字符串的转换 文件名:控制器/ content.php 行号:64 ** ,也忘记了循环变量 消息:未定义的变量:链接 消息:未定义的变量:结果 –

+0

这是64行?请说明你想清楚解决的问题。 –

回答

0

编辑模型与此

public function getLiveFeed($limit = NULL, $start = NULL) { 

$this->db->select('*'); 
$this->db->where('status', 1); 
$this->db->from('rs_tbl_live'); 
$this->db->limit($limit, $start); 
$query = $this->db->get(); 

    if($query->num_rows() > 0) { 
     return $query; 
    } else { 
     return false; 
    } 
} 

In View显示像这样。

<?php foreach ($results->result() as $rowTV) { ?> 
<div class="unit item movie-item pull-left" data-key="<?=$rowTV->id;?>"> 
    <a href="" class="ChannelCov"> 
     <img src='<?=IMAGE_PATH.$rowTV->img;?>' width="100%" alt="#LifeIsMusic <?=$rowTV->name;?>" title="<?=$rowTV->name;?>" /> 
    </a> 
    <h2><a href=""><?=$rowTV->name;?></a></h2> 
</div> 
<?php } ?>  
+0

感谢您的帮助。但是当我试试这个分页将不起作用:( –

+0

你的意思是什么都没有发生,当你点击下一页? –

+0

乐意帮忙。 祝你好运 –