I am new to php... I have developed ajax dynamic dependent dropdown in codeigniter and it works, what i want is to when the last dropdowns's option is select it should show the image for selected option plz help
view and ajax:
<div id="student_img">
<img src="" class="student_img">
</div>
<script>$('#student').change(function()
{
var s_id = $('#student').val();
if(s_id != ''){
$.ajax({
url:"<?php echo base_url(); ?>dynamic_controller/fech_student_img",
method:"POST",
data:{s_id:s_id},
success:function(data){
$('#student_img').html(data);
}
})
}
});</script>
controller:
public function fech_student_img(){
if($this->input->post('s_id'))
{
echo $this->dynamic_model->fech_student_img($this->input->post('s_id'));
}
}
Model ftn:
public function fech_student_img($s_id){
$query = $this->db->select('s_img')->from('student')->where('s_id',$s_id)->get();
$q = $query->result();
$output = '<img src="'.$q.'">';
return $output;
}
Message: Array to string conversion
Filename: models/dynamic_model.php