Welcome Guest, Not a member yet? Register   Sign In
How to retrieve employee id in a input box based on employee name drop down from database ??
#11

[eluser]rainfall[/eluser]
Hmmm
j query is working Now after put the base_url in src.

But in input box its not showing the id ..

.its showing the name that i selected from the dropdown
#12

[eluser]Flemming[/eluser]
Great! So now the input box is showing the correct name when you change the select?

Check this:

Code:
foreach($groups as $row)
            {
              echo '<option value="'.$row->employee_name.'">'.$row->employee_name.'</option>';
            }

You are using employee_name as the option value, so that is what will get inserted into the input box. You will need to change the option value to $row->employee_id (or whatever the ID field is called in the database)
#13

[eluser]Flemming[/eluser]
The complete solution (and kind of like ivantcholakov suggested):

Model
Code:
$query = $this->db->query("SELECT emp_id,employee_name FROM tbl_sample ORDER BY employee_name");
return $query;

View
Code:
foreach($query->result() as $employee)
            {
              echo '<option value="'.$employee->emp_id.'">'.$employee->employee_name.'</option>';
            }
#14

[eluser]rainfall[/eluser]
Wooowww .. its working now Smile

You guys are awesome

Thnx a lot




Theme © iAndrew 2016 - Forum software by © MyBB