0

I am having a if loop like this:

if(!empty($all_msg_e))
{ print_r($all_msg_e);

        foreach($all_msg_e as $ae)
        {
            echo $ae['msg_desc']."<br>";
            display($ae['msg_id']);
        }
}

and the function display() is :

function display($msg_id,$obj)
{
    
    $this->db->select("*");
    $this->db->from("et_msg");
    $this->db->where("link_to",$msg_id);
    $child_msg=$this->db->get()->result_array();
    
    print_r($child_msg);die;
        echo $child_msg['msg_desc']."<br>";
        echo $child_msg['msg_id']."<br>";
        $msg_id=$child_msg['msg_id']."<br>";    
    
    display($msg_id);
}

here I was getting error: Using $this when not in object context

then referencing this answer I replaced $this with any variable $obj

$obj->db->select("*");
    $obj->db->from("et_msg");
    $obj->db->where("link_to",$msg_id);
    $query = $obj->db->get();

then it started giving error like:Call to a member function select() on a non-object

The concept behinde all this is: I am having table named "et_msg" and in that several message between two person are being stored. The conversation is linked by storing one message's id to another messages' "link_to" field. And I want to display the conversation one after another manner

Whats wrong is being done?? Completely Stuck..

P.S. I am using CodeIgniter for the same

Community
  • 1
  • 1
KAsh
  • 304
  • 5
  • 23

1 Answers1

0

Added the function display in a class

and it worked well.. :)

KAsh
  • 304
  • 5
  • 23
  • Please don't add "thank you" as an answer. Instead, vote up the answers that you find helpful. – Echilon Mar 02 '13 at 11:27
  • which ans dear?? I got solution and that I posted as ans.. and if you will post helpful ans I ll definitely accept it (or vote up it) – KAsh Mar 02 '13 at 12:16