<?php
class Dynamic_dependent_model extends CI_Model
{
 function fetch_level()
 {
  $this->db->order_by("level_id", "ASC");
  $query = $this->db->get("level");
  return $query->result();
 }

 function fetch_fac($level_id)
 {
  $this->db->where('level_id', $level_id);
  $this->db->order_by('fac_id', 'ASC');
  $query = $this->db->get('fac');
  $output = '<option value="">اختر الكليّة</option>';
  foreach($query->result() as $row)
  {
   $output .= '<option value="'.$row->fac_id.'">'.$row->fac_name.'</option>';
  }
  return $output;
 }

 function fetch_dept($fac_id)
 {
  $this->db->where('fac_id', $fac_id);
  $this->db->order_by('dept_name', 'ASC');
  $query = $this->db->get('dept');
  $output = '<option value="">البرنامج الأكاديمي</option>';
  foreach($query->result() as $row)
  {
   $output .= '<option value="'.$row->dept_id.'">'.$row->dept_name.'</option>';
  }
  return $output;
 }
}

?>

