0

im new to codeignitor and suffering to store a database value in array and pass it through other page

$query = $this->db->query("YOUR QUERY");
foreach ($query->result() as $row)
{
    echo $row->title;
    echo $row->name;
    echo $row->body;
}

instead of echo it should be stored in array and pass it to other page as a argument.. is it possible??

1

1 Answer 1

3

This code return the query result as array, now you can use the array inside your controller and pass it to your view.

$data = array();

foreach ($query->result() as $row)
{
    $data[] = array(
        'title' => $row->title,
        'name'  => $row->name,
        'body'  => $row->body
    );
}

return $data;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.