Welcome Guest, Not a member yet? Register   Sign In
Database, Selecting Data help.[solved]
#1

[eluser]Ivar89[/eluser]
It's anoying me i can't figure out the syntax...I mean with normal php I can do it but with CodeIgniter I am stuck as hell
I just need to get my data from database and acho it in a table.

Code:
function Get_Blog_Data($query)
    {
        $this->db->select('strBlogTitle', 'ID_Blog', 'ID_Language');
        $query = $this->db->get('tblblog');
        
        foreach ($query->result() as $row)
        {
            $query = $row->strBlogTitle;
        }
        return $query->result();
    }
i tried manyu things but not working...
I probably overlooked something stupid

this is my model btw;
Code:
function index()
    {
        $this->blog_insert_model->Get_Blog_Data($_POST);
        $this->load->view('blog/index');
    }
#2

[eluser]Rob Gordijn[/eluser]
first: lookup the manual -> database: selecting data, generating result and active record.

model:
Code:
function Get_Blog_Data()
{
    return $this->db->select('strBlogTitle, ID_Blog, ID_Language')->get('tblblog')->result();
}

control:
Code:
function index()
{
    $data['blogs'] = $this->blog_model->Get_Blog_Data();
    $this->load->view('myview', $data);
}

view:
Code:
foreach($blogs as $blog)
{
    echo $blog->strBlogTitle.'<br />';
}

hope it helps you going the right direction....

[edit] typo's etc
#3

[eluser]Ivar89[/eluser]
that actually helped ALLOT!

thanks^^
#4

[eluser]Rob Gordijn[/eluser]
no problemo Smile




Theme © iAndrew 2016 - Forum software by © MyBB