Welcome Guest, Not a member yet? Register   Sign In
Trouble pass array from DB, model to view
#2

[eluser]PhilTem[/eluser]
Your code - in general - isn't wrong. Though I am wondering what this part should actually do/produce

Code:
foreach ($query_con->result_array() as $row)
{
  $row['con_id'];
  $row['name'];
}
return $row;

You are just looping over each row and basically do nothing but waste time Wink You probably want something like

Code:
function call_country()
{
  $this->db->select('con_id, name');
  $query_con = $this->db->get('geo_countries');
  
  $return = array();
  
  foreach ($query_con->result_array() as $row)
  {
    $return[$row['con_id']] = $row['name'];
  }
  
  return $return;

}

This way you will get an array which you can easily pass to form_dropdown.


Messages In This Thread
Trouble pass array from DB, model to view - by El Forum - 06-07-2012, 12:47 PM
Trouble pass array from DB, model to view - by El Forum - 06-07-2012, 12:56 PM
Trouble pass array from DB, model to view - by El Forum - 06-07-2012, 01:03 PM
Trouble pass array from DB, model to view - by El Forum - 06-07-2012, 04:08 PM
Trouble pass array from DB, model to view - by El Forum - 06-07-2012, 07:03 PM
Trouble pass array from DB, model to view - by El Forum - 06-08-2012, 12:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB