"create dynamic dropdown on codeigniter" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "create dynamic dropdown on codeigniter" answered properly. Developers are finding an appropriate answer about create dynamic dropdown on codeigniter related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like create dynamic dropdown on codeigniter. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on create dynamic dropdown on codeigniter.
create dynamic dropdown on codeigniter
CREATE DYNAMIC DROPDOWN IN CONDEIGNITER
---------------------------
BASE MODEL
---------------------------
public function convertObjectToArray($data) {
if (is_object($data)) {
$data = get_object_vars($data);
}
if (is_array($data)) {
// return array_map(__FUNCTION__, $data);
return array_map(array($this, 'convertObjectToArray'), $data);
}
return $data;
}
public function generate_dropdownOption($query){
$query = $this->db->query($query);
$results =$this->convertObjectToArray($query->getResult());
$html = '';
foreach ($results as $row){
row = array_values($row);
$html .='<option value="'.$row[0].'">'.ucwords($row[1]).'</option>';
}
return $html;
}
public function getDropdown_sex(){
$query = "SELECT sex_ID,sex_Name FROM `ref_sex`";
return $this->generate_dropdownOption($query);
}
public function getDropdown_marital(){
$query = "SELECT marital_ID,marital_Name FROM `ref_marital`";
return $this->generate_dropdownOption($query);
}
---------------------------
CONTROLLER
---------------------------
public function HomePage()
{
$pageData = [
'dropdown' =>[
'sex'=> $this->baseModel->getDropdown_sex(),
'marital'=> $this->baseModel->getDropdown_marital(),
]
];
return view('your_viewfile_here',$pageData);
}
---------------------------
VIEW:
---------------------------
<select class="form-control" id="profile_sex" name="profile_sex" required="">
<?php echo $this->data['dropdown']['sex']?>
</select>
----------
If you want to update it the dropdown without loading,
just use ajax to call route for getting dropdown :)
[Support Links!]
Ko-fi: https://ko-fi.com/rhalp10
Paypal: https://paypal.me/rhalp10
All those coders who are working on the Whatever based application and are stuck on create dynamic dropdown on codeigniter can get a collection of related answers to their query. Programmers need to enter their query on create dynamic dropdown on codeigniter related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about create dynamic dropdown on codeigniter for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of create dynamic dropdown on codeigniter while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "create dynamic dropdown on codeigniter". Visit this developer's friendly online web community, CodeProZone, and get your queries like create dynamic dropdown on codeigniter resolved professionally and stay updated to the latest Whatever updates.