[eluser]Dandy_andy[/eluser]
This should be relatively simple, but I'm stuck. I have a DB with a table that has some country geo data organised in two rows:- country id (con_id) and country name (name). I have created a Model to extract the data from the DB and I want to pass it to the controller and then on to my view so that I can populate a dropdown list. But I'm having trouble passing an array.
Here is my data...
MODEL:-
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Geo_options extends CI_Model {
//call geo country options
function call_country() {
$this->db->select('con_id, name');
$query_con = $this->db->get('geo_countries');
foreach ($query_con->result_array() as $row)
{
$row['con_id'];
$row['name'];
}
return $row;
}
}
?>
PART OF THE CONTROLLER:-
Code:
<?php
class User extends CI_Controller {
function myprofile()
{
$this->load->model('geo_options');
$data['country'] = $this->geo_options->call_country();
$this->load->view('myprofile', $data);
}//function index
}
?>
MY VIEW (written just to test the output at the moment but what I want to do is populate an HTML dropdown list with the relevant options values and names:-
Code:
<?php echo $country; ?>
I know I have done something very wrong with passing the array and I would appreciate some help on this... I'm learning slowly but surely!
Thanks in advance.