Welcome Guest, Not a member yet? Register   Sign In
invoke controll from view?
#11

[eluser]Smy[/eluser]
controller: news.php

Code:
function index()
    {
        $this->load->model('NewsModel','newsObj');
        $result['news'] = $this->newsObj->getNews(); // function to retrieve the news
        $this->load->view('news', $result);
    }


Model : newsModel.php

Code:
function getNews(){
        $sql="SELECT * FROM tb_news";
        $result = $this->db->query($sql);
        $res=$result->result();
        
        return $res;
    }

function getAttachment($newsID){
        $sql="SELECT * FROM tb_attachment where newsId = $newsID";
        $result = $this->db->query($sql);
        $res=$result->result();
        
        return $res;
    }

view: news.php

Code:
echo meta('Content-type', 'text/html; charset=utf-8', 'equiv');
foreach ($news as $row)
{
    echo $row->chvNewsTitle;
    echo br(1);
  
}

If i need to display the attachment along with the news Title, how can i call the model getAttachment($row->newsID) from my view


Messages In This Thread
invoke controll from view? - by El Forum - 03-07-2011, 05:28 AM
invoke controll from view? - by El Forum - 03-07-2011, 07:06 AM
invoke controll from view? - by El Forum - 03-07-2011, 07:07 AM
invoke controll from view? - by El Forum - 03-07-2011, 08:02 AM
invoke controll from view? - by El Forum - 03-07-2011, 08:10 AM
invoke controll from view? - by El Forum - 03-07-2011, 03:37 PM
invoke controll from view? - by El Forum - 03-07-2011, 09:22 PM
invoke controll from view? - by El Forum - 03-08-2011, 12:47 AM
invoke controll from view? - by El Forum - 03-08-2011, 12:54 AM
invoke controll from view? - by El Forum - 03-08-2011, 01:47 AM
invoke controll from view? - by El Forum - 03-10-2011, 10:58 PM
invoke controll from view? - by El Forum - 03-11-2011, 08:15 AM
invoke controll from view? - by El Forum - 03-11-2011, 09:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB