[eluser]BrianDHall[/eluser]
[quote author="joeizang" date="1254943868"]
Code:
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;
}
}
}
[/quote]
Your problem is your foreach. What is happening is the foreach gets one of the values in the $Q array and puts it into $value, then you call return - that breaks for the foreach loop and ends the function.
Doing it this way will ensure you never get more than the first result. Replace "return $value;" with "echo $value;" to see if it works.