I populate drop down list from mysql database and it shouldn't containt repeated values.
I try to use distinct keyword but failed to use. What is the logic I should use?
Example:
I have two bsc and two Bachelor in Mechanical in dropdown option and I want to display one bsc and one dropdown and similar for other course.
My codeigniter query is not working properly. The dropdown option is selected dynamically. How to solve it?
This is my controller
$courserecord = $this->front->get_data_wheree('tbl_course_offered.course_offrd_name');
$data['collg_id'] = json_decode(json_encode($courserecord), True);
if (empty($data['collg_id'])) {
$data['collg_id'] = json_decode(json_encode($courserecord), True);
} else {
$courserecord = $this->front->get_data_wheree('tbl_course_offered.course_offrd_name');
$data['collg_id'] = json_decode(json_encode($courserecord), True);
}
This is my view file
<div class="col-md-2">
<div class="form-group">
<div class="col-md-12">
<select name="course_offrd_name" id="course_offrd_name" onchange='' class="form-control ui fluid dropdown">
<option value="">Select Course</option>
<?php foreach($coursedata as $val)
{
?>
<option value="<?php echo $val->course_id?>" <?php if(isset($course_offrd_name)) { if($course_offrd_name==$val->course_id) { ?>selected
<?php } }?> >
<?php echo $val->course_id;?>
</option>
<?php }?>
</select>
</div>
</div>
</div>
This is my model file
function get_data_wheree($table,$where)
{
return $this->db->distinct($table,$where)->result();
}