Welcome Guest, Not a member yet? Register   Sign In
How to bind and output data to codeigniter 3
#1

(This post was last modified: 11-10-2022, 09:39 PM by NorahDaniels.)

I have two tables in the database, one stores a list of departments (id and name), and the other a list of doctors, and each doctor is attached to the department, while in the table of doctors, the doctor is attached to the department by department id. My task is to display a list of doctors in a bootstrap table and so that the department field displays not the department ID but the name of the omegle department, developerbook chatrandom how can I do it?

view

    <!-- Table with stripped rows -->
          <table class="table datatable" id="example">
            <thead>
              <tr>
                <th scope="col">#</th>
                <th scope="col">Name</th>
                <th scope="col">Email</th>
                <th scope="col">Department</th>
                <th scope="col">Phone</th>
              </tr>
            </thead>
            <tbody>
            <?php $i = 1; ?>
            <?php foreach ($doctors_list as $dl) : ?>
              <tr>
                <th scope="row"><?= $i; ?></th>
                <td><?= $dl['name']; ?></td>
                <td><?= $dl['email']; ?></td>
                <td><?=$dl['department']; ?> </td>
                <td><?= $dl['phone']; ?></td>
              </tr>
              <?php $i++; ?>
                <?php endforeach; ?>
            </tbody>
          </table>
controller

    public function doctors_list()
{
    $data['title'] = 'Dashboard';
    $data['user'] = $this->db->get_where('user', ['email' => $this->session->userdata('email')])->row_array();
    $data['doctors_list'] = $this->db->get_where('user', ['role_id' => 2])->result_array();
    $data['department_list'] = $this->db->get('departments')->result_array();

    $this->form_validation->set_rules('name', 'Name', 'required|trim');
    $this->form_validation->set_rules('email', 'Email', 'required|trim|valid_email|is_unique[user.email]', [
        'is_unique' => 'This email has already registered!'
    ]);
    $this->form_validation->set_rules('password1', 'Password', 'required|trim|min_length[3]|matches[password2]', [
        'matches' => 'Password dont match!',
        'min_length' => 'Password too short!'
    ]);
    $this->form_validation->set_rules('password2', 'Password', 'required|trim|matches[password1]');


    if ($this->form_validation->run() == false) {
      $this->load->view('templates/header', $data);
    $this->load->view('templates/sidebar_admin', $data);
    $this->load->view('admin/doctors_list', $data);
  $this->load->view('templates/footer');
    } else {
        $email = $this->input->post('email', true);
        $role_id = $this->input->post('role_id', true);
        $department = $this->input->post('department', true);
        $data = [
            'name' => htmlspecialchars($this->input->post('name', true)),
            'email' => htmlspecialchars($email),
            'image' => 'default.jpg',
            'password' => password_hash($this->input->post('password1'), PASSWORD_DEFAULT),
            'role_id' => htmlspecialchars($role_id),
            'department' => htmlspecialchars($department),
            'phone' => htmlspecialchars($this->input->post('phone', true)),
            'is_active' => 1,
            'date_created' => time()
        ];

        $this->db->insert('user', $data);

        $this->session->set_flashdata('message', '<div class="alert alert-success" role="alert">Congratulation! your account has been created. Please activate your account </div>');
        redirect('admin/doctors_list');
    }
i am trying to do so

<?=$department_list[$dl['department']]; ?>
but i get an error
Reply




Theme © iAndrew 2016 - Forum software by © MyBB