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

(This post was last modified: 10-29-2014, 09:25 AM by Maijane.)

[b]I need a help I am new in codeigniter I am create a capturing tool for member I want to create a dropdown list which includes

Country
State
Region
branch name
[/b]

here is my controller
/****MANAGE MEMBER*****/
function member($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('admin_login') != 1)
redirect(base_url(), 'refresh');
if ($param1 == 'create') {
$data['membership_no'] = $this->input->post('membership_no');
$data['first_names'] = $this->input->post('first_names');
$data['last_name'] = $this->input->post('last_name');
$data['initials'] = $this->input->post('initials');
$data['title'] = $this->input->post('title');
$data['id_number'] = $this->input->post('id_number');
$data['passport_no'] = $this->input->post('passport_no');
$data['birthday'] = $this->input->post('birthday');
$data['gender'] = $this->input->post('gender');
$data['phone'] = $this->input->post('phone');
$data['email'] = $this->input->post('email');
$data['address_1'] = $this->input->post('address_1');
$data['address_2'] = $this->input->post('address_2');
$data['address_3'] = $this->input->post('address_3');
$data['city'] = $this->input->post('city');
$data['province'] = $this->input->post('province');
$data['country'] = $this->input->post('country');
$data['postal_code'] = $this->input->post('postal_code');
$data['branch'] = $this->input->post('branch');
$data['tier'] = $this->input->post('tier');
$data['join_date'] = $this->input->post('join_date');
$data['expiry'] = $this->input->post('expiry');
$data['status'] = $this->input->post('status');
$data['discount'] = $this->input->post('discount');
$this->db->insert('member', $data);
$member_id = mysql_insert_id();
move_uploaded_file($_FILES['userfile']['tmp_name'], 'uploads/member_image/' . $member_id . '.jpg');
$this->email_model->account_opening_email('member', $data['email']); //SEND EMAIL ACCOUNT OPENING EMAIL
redirect(base_url() . 'index.php?admin/member/', 'refresh');


}

function buildDropCities($member){
//set selected country id from POST
$id_country = $this->input->post('id',TRUE);

//run the query for the cities we specified earlier
$districtData['districtDrop']=$this->cities_countries_model->getCitiesByCountry($id_country);

$output = null;

foreach ($cityData['cityDrop']->result() as $row)
{
//here we build a dropdown item line for each query result
$output .= "<option value='".$row->id."'>".$row->City."</option>";
}

echo $output;

$page_data['countryDrop'] = $this->cities_countries_model->getCountries();
$page_data['page_name'] = 'member';
$page_data['page_title'] = get_phrase('manage_member');
$this->load->view('index', $page_data);

}



and here is my view

<div class="control-group">
<label class="control-label"><?php echo get_phrase('country');?></label>
<div class="controls">
<?php echo form_dropdown('countriesDrp', $countryDrop,'','class="required" id="countriesDrp"'); ?>
</div>
</div>

<div class="control-group">
<label class="control-label"><?php echo get_phrase('city');?></label>
<div class="controls">
<select name="cityDrp" $cityDrop id="cityDrp">
<option value="">Select</option>
</select>
</div>
</div>

please help

and here is my model

<?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;
}

}


I have attached more info
The first field load okay but the second one doesnt
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