Welcome Guest, Not a member yet? Register   Sign In
I ended up with having some logic in my View ! need help
#1

[eluser]Faisal Alghamdi[/eluser]
Hi everyone,

I have been playing with Ci for a while..

Regarding this code,


controller
Code:
function ser()


{


  $data = array (
  'register' => 'register_view',
  'options' => 'options_view',
  'search' => 'search',
  'ser' => 'ser_view',  // my view file.
  'script' => 'example_script');
  
  
  $this->load->view('include/query', $data);
}
VIEWS

view in include/query
Code:
<?php $this->load->view('include/header'); ?>
<?php $this->load->view($ser); ?>
<?php $this->load->view('include/footer'); ?>

view in /ser_view
Code:
<div id="content_main">
<div id="content">
&lt;?php
$s = $this->input->GET('job_name');
$c = $this->input->GET('city');
     $this->db->select('*');
  $this->db->select_avg('SALARY');
  $this->db->select_avg('BOUNS');
  $this->db->from('main_records');
  $this->db->where('JOB_NAME',$this->input->GET('job_name'));
  
  if($this->input->GET('city')!='all') {
    $this->db->where('CITY_NAME',$this->input->GET('city'));
}
$this->db->where('approval',1);
  
  $this->db->join('the_cities', 'the_cities.ID_CITY = main_records.CITY','left');
  $this->db->join('categories', 'categories.idCATEGORIES = main_records.CATE','left');
  $this->db->join('experience', 'experience.idEXPERIENCE = main_records.EXPERIEANCE','left');
  $this->db->group_by('CITY');
  if($this->input->GET('sort')=='lowest') {
  $this->db->order_by('SALARY','asc');
  } else if ($this->input->GET('sort')=='highest') {
   $this->db->order_by('SALARY','desc');
  }
  $this->db->group_by('EXPERIEANCE');
  $q = $this->db->get();
  
   if($q->result()==NULL) {
   echo "No result";
  }
  
   if ($this->input->GET('job_name')) {
   foreach($q->result() as $row){
  $t = $row->SALARY+$row->BOUNS;
   echo $row->JOB_NAME." ";
   echo $row->CITY_NAME." ";
   $exp = $row->EXPERIEANCE;
        echo " ".$row->PERIOD.br(2);


  }
}

  
  ?&gt;

</div>
</div>

I could not use the queries as MODEL neither as a controller. is there any way that I can use in order to solve this problem out ?

Thanks
#2

[eluser]Faisal Alghamdi[/eluser]
Thank you so much.. works like a charm!




Theme © iAndrew 2016 - Forum software by © MyBB