[eluser]webdezzo[/eluser]
Hey all,
I have an issue where I am pulling a single record from my database. It returns the record just fine as :
Code:
Array
(
[0] => stdClass Object
(
[id] => 1
[news_date] => 1185384665
[news_title] => The Test Title
[news_sub_title] => The Test Sub Title
by using the following code within my controller:
Code:
function details($id){
// Load Model
$this->load->model('News_model','News');
$main_data['news_details'] = $this->News->list_news($id);
// Template Information
$template_data['header'] = $this->load->view('content/header', array(), true);
$template_data['navigation'] = $this->load->view('content/navigation', array(), true);
$template_data['main_content'] = $this->load->view('content/news_details', $main_data, true);
// Load Template
$this->load->view('templates/subpage', $template_data);
}
which is fine. My problem is when I want to echo out my result within in my view, I really want to be able to just echo something like this:
Code:
<?= $news_details->$detail->news_title; ?>
instead of having to loop through a foreach each time like this:
Code:
<? foreach($news_details as $detail){ ?>
<?= $detail->news_title ?>
<? } ?>
in order to get my single record to spit out. Am I missing something? Or is there a better way to do this?
Thanks in advance!
-undecisive