Welcome Guest, Not a member yet? Register   Sign In
I need a help with dropdown list
#6

<?php
class cities_countries_model extends CI_Model {

public function __construct()
{
$this->load->database();
}

//fill your country dropdown
public function getCountries()
{
$this->db->select('id,Country');
$this->db->from('Countries');
$query = $this->db->get();

foreach($query->result_array() as $row){
$data[$row['id']]=$row['Country'];
}
return $data;
}

//fill your cities dropdown depending on the selected city
public function getCityByCountry($id_country=string)
{
$this->db->select('id,city');
$this->db->from('cities');
$this->db->where('id_country',$id_country);
$query = $this->db->get();

return $query;
}

}

here is my model
Reply


Messages In This Thread
I need a help with dropdown list - by Maijane - 10-29-2014, 01:30 AM
RE: I need a help with dropdown list - by Maijane - 10-29-2014, 09:18 AM
RE: I need a help with dropdown list - by Maijane - 10-29-2014, 09:15 AM
RE: I need a help with dropdown list - by Maijane - 10-29-2014, 09:17 AM
RE: I need a help with dropdown list - by Maijane - 10-29-2014, 09:17 AM
RE: I need a help with dropdown list - by Maijane - 10-29-2014, 09:19 AM
RE: I need a help with dropdown list - by ciadmin - 10-29-2014, 08:40 PM
RE: I need a help with dropdown list - by Maijane - 10-30-2014, 06:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB