php - Searching data with combobox codeigniter -


i'm giovanni, got problem on code, seems code work why result unmatch values on combobox..

can tell me what's wrong?

here's code (on controller. function pencarian_indeks)

function pencarian_indeks() {      //muat library form validation     $this->load->library('form_validation');      if(isset($_post['submit']))         {         //set aturan validasi untuk setiap field isian     $this->form_validation->set_rules('tanggal', 'tanggal', 'required');     $this->form_validation->set_rules('kategori', 'kategori', 'required');     $this->form_validation->set_rules('tahun', 'tahun', 'required');     $this->form_validation->set_rules('bulan', 'bulan', 'required');       //cek apakah form validasi berhasil     if ($this->form_validation->run() == false)//jika validasi gagal     {      $this->session->set_flashdata('pesan', validation_errors());     redirect(base_url() . 'indeks');     }     else //jika validasi berhasil     {     $data['kategori'] = $this->input->post('kategori');     $data['tanggal'] = $this->input->post('tanggal');     $data['bulan'] = $this->input->post('bulan');     $data['tahun'] = $this->input->post('tahun');          $this->db->where('day(created_at)',$data['tanggal']);         $this->db->where('month(created_at)',$data['bulan']);         $this->db->where('year(created_at)',$data['tahun']);          $this->db->where('kategori', $data['kategori']);         $this->db->from('news');          //pagination init         $pagination['base_url']     = base_url().'/pencarian/index/page/';         $pagination['total_rows']   = $this->db->count_all_results();         $pagination['full_tag_open'] = "<p><div class=\"pagination\">";         $pagination['full_tag_close'] = "</div></p>";         $pagination['cur_tag_open'] = "<span class=\"current\">";         $pagination['cur_tag_close'] = "</span>";         $pagination['num_tag_open'] = "<span class=\"disabled\">";         $pagination['num_tag_close'] = "</span>";         $pagination['per_page']     = "3";         $pagination['uri_segment'] = 4;         $pagination['num_links']    = 4;          $this->pagination->initialize($pagination);          $data['query'] = $this->news_model->indeks_berita($pagination['per_page'],$this->uri->segment(4,0),$data['tahun'],$data['bulan'],$data['tanggal'],$data['kategori']);          print_r($data['query']);//coba dicek dlu datanya..          exit;          $this->load->vars($data);         $data['hasil5'] = $this->news_model->tampil_populer(2);         $data = array_merge($data,admin_info());         $this->parser->parse('frontend/indeks/indeks',$data);      }         } else {            echo "hasil pencarian tidak ditemukan!!";         }    } 

and on model (function indeks_berita)

    function indeks_berita($perpage, $uri,$tanggal,$bulan,$tahun,$kategori) {     $this->db->select('*');      if($tahun)         $this->db->where('year(created_at)',$tahun);     if($bulan)         $this->db->where('month(created_at)',$bulan);     if($tanggal)         $this->db->where('day(created_at)',$tanggal);     if($kategori)         $this->db->where('kategori', $kategori);     $this->db->order_by('id', 'asc');      $getdata = $this->db->get('news', $perpage, $uri);      print_r ($this->db->last_query());     //print_r ($getdata->result_array());     exit();      if ($getdata->num_rows() > 0){         return $getdata->result_array();     }else{         return null;     } } 

on view (the comboboxes)

<p>lihat arsip tanggal :     <select name="kategori">             <option value="" selected>pilih kategori</option>             <option value="news">news</option>             <option value="bandung_city">bandung city</option>             <option value="hot_gossip">hot gossip</option>             <option value="sainstek">sains & tek</option>             <option value="kriminal">kriminalitas</option>             <option value="persibnews">#persibonthenews</option> </select>     <select name="tahun">             <option value="" selected>pilih tahun</option>             <option value="2013">2013</option>             <option value="2014">2014</option>             <option value="2015">2015</option>             <option value="2016">2016</option>             <option value="2017">2017</option>             <option value="2018">2018</option> </select> <select name="bulan">             <option value="" selected>pilih bulan</option>             <option value="1">januari</option>             <option value="2">februari</option>             <option value="3">maret</option>             <option value="4">april</option>             <option value="5">mei</option>             <option value="6">juni</option>             <option value="7">juli</option>             <option value="8">agustus</option>             <option value="9">september</option>             <option value="10">oktober</option>             <option value="11">november</option>             <option value="12">desember</option> </select>  <select name="tanggal">             <option value="" selected>pilih</option>             <option value="1">1</option>             <option value="2">2</option>             <option value="3">3</option>             <option value="4">4</option>             <option value="5">5</option>             <option value="6">6</option>             <option value="7">7</option>             <option value="8">8</option>             <option value="9">9</option>             <option value="10">10</option>             <option value="11">11</option>             <option value="12">12</option>             <option value="13">13</option>             <option value="14">14</option>             <option value="15">15</option>             <option value="16">16</option>             <option value="17">17</option>             <option value="18">18</option>             <option value="19">19</option>             <option value="20">20</option>             <option value="21">21</option>             <option value="22">22</option>             <option value="23">23</option>             <option value="24">24</option>             <option value="25">25</option>             <option value="26">26</option>             <option value="27">27</option>             <option value="28">28</option>             <option value="29">29</option>             <option value="30">30</option>             <option value="31">31</option> </select>  <input type="submit" value="cari!" name="cari" id="cari"/> 

and here's output query when submitted code :

select * (`news`) year(created_at) = '2' , month(created_at) = '17' , day(created_at) = 'bandung_city' , `kategori` = '2014' order `id` asc limit 3 

(seems not right)

thank you, i'm glad if me find what's wrong

your form action seems incorrect not have indeks method inside indeks contorller.

change below

<form action="<?php echo base_url(); ?>indeks/pencarian_indeks" method="post">


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -