Welcome Guest, Not a member yet? Register   Sign In
Help me traverse my query database result into each row and each column?
#1

[eluser]Edy S[/eluser]
Hi, im new in codeIgniter, now that i have the problem to traverse my query result . here is my code i juts try to learn :
This is the code of my Blogmodel
Code:
<?php

class Blogmodel extends CI_Model {

    var $title   = '';
    var $content = '';
    var $date    = '';

    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
    
    function get_last_ten_entries(){
        $query = $this->db->get('sys_prmpost', 10);
        return $query->result_array();
    }

And this is the code in my controller called blog

Code:
<?php
class Blog extends CI_Controller {

    public function index(){
        
    }
    //---------------------------------------------------------------
    //display latest ten post
    //---------------------------------------------------------------
    public function post(){
        $data['page_title'] = "Our list posted tutorials";
                
        $this -> load->model('Blogmodel');
        $data['post']    = $this -> Blogmodel ->get_last_ten_entries();
        $this -> load->view('post',$data);
    }
    
}
?>

Then my problem is how to traverse result from
Code:
$data['post']    = $this -> Blogmodel ->get_last_ten_entries();
in my views. I means that my table is contain with column postID,Title,Details.
Then what should i do if i want to use each column, for example if i want to use it in the link :
Code:
http://example.com/index.php/blog/my_post_id_here

Thanks for everybody who can help resolve my problem...


Messages In This Thread
Help me traverse my query database result into each row and each column? - by El Forum - 06-11-2011, 10:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB