[eluser]joeizang[/eluser]
hi y'all,
I have another question that I need help with.
Now I know that when you query the database with CI activerecord, it usually returns multidimensional array's if there is more than one row returned. I want to populate list items on my html page with titles from a database. with my code all i get returned is one title. using php functions like var_dump etc I see that the result is multidimensional. what do I do? here is a sample of my code:
<ul>
<li><a href="#" id="article9">text1</a></li>
<li><a href="#" id="article10">Ttext2</a></li>
<li><a href="#" id="article11">Text3</a></li>
</ul>
<?php
function gettitle3()
{
$this->db->select('articletitle');
$this->db->from('articles');
$this->db->where('articlecategory',2);
$query = $this->db->get();
if($query->num_rows() > 0)
{
$Q = $query->result_array();
foreach($Q as $value){
return $value;
}
}
}
$answer = $this->articles->gettitle3();
if($answer){
$data['heads'] = $answer;
}
$this->load->view('dummy_view',$data);
foreach($heads as $tails)
{
//var_dump($t);
//print_r($t)."<br />";
echo $tails['articletitle'];
// var_dump($tails);
}
?>