[eluser]Flemming[/eluser]
The way I would do it is write a helper.
Create a new helper in 'application > helpers' called for example, general_helper.php :
Code:
<?php
// general_helper.php
function get_body($id)
{
// here you need to use the CI super object like so:
$CI = &get;_instance();
// now you can access the database via $CI instead of $this, eg.
$CI->db->select('BODY')->from('MY_TABLE')->where('ID', $id);
$query = $CI->db->get();
$result = $query->row();
$body = $result->BODY;
return $body
}
Include the new helper in the constructor of your controller:
Code:
function __construct()
{
$this->load->helper('general_helper');
}
Now in your view you can call the helper function like this:
Code:
<h1>Hello World</h1>
<p><?php echo get_body($id_you_are_passing_in)?></p>