Welcome Guest, Not a member yet? Register   Sign In
Help Me... Search with dropdown menu or radio button
#2

[eluser]Flemming[/eluser]
Hmmm ... how did you get so far and then not know how to add extra criteria to your search?

anyway - hopefully this will get you started (it isn't complete code, only enough to give you some clues!)

Model
Code:
function SearchResult($perPage,$uri,$judul,$editor,$pengarang)
{
    $this->db->select('*');
    $this->db->from('tbl_master_properti');
    if(!empty($judul)) {
        $this->db->like('judul',$judul);
    }
    if(!empty($editory)) {
        $this->db->like('editor',$editor);
    }
    if(!empty($pengarang)) {
        $this->db->like('pengarang',$pengarang);
    }

controller
Code:
function index()
{
    if(isset($_POST['submit']))
    {
        $data['judul'] = $this->input->post('judul');
        $this->session->set_userdata('sess_judul', $data['judul']);
        $data['editor'] = $this->input->post('editor');
        $this->session->set_userdata('sess_editor', $data['editor']);
        $data['pengarang'] = $this->input->post('pengarang');
        $this->session->set_userdata('sess_pengarang', $data['pengarang']);
        
    //...
    
    // pass the extra post data to your model
    $data['ListBerita'] = $this->pencarianmodel->SearchResult($pagination['per_page'],$this->uri->segment(4,0),$data['judul'],$data['editor'],$data['pengarang']);
    
    //...
    }

view
Code:
<input name="editor" type="text" id="editor" size="30" maxlength="255" class="inputbox" value="<?=$editor;?>"/>

<!-- or for a select (dropdown): -->

<select name="editor" id="editor">
    <option value="some_value">Editor One</option>
    <option value="some_value2">Editor Two</option>
    <option value="some_value3">Editor Three</option>
</select>


Messages In This Thread
Help Me... Search with dropdown menu or radio button - by El Forum - 06-16-2010, 01:22 AM
Help Me... Search with dropdown menu or radio button - by El Forum - 06-16-2010, 06:06 AM
Help Me... Search with dropdown menu or radio button - by El Forum - 06-16-2010, 07:26 AM
Help Me... Search with dropdown menu or radio button - by El Forum - 06-16-2010, 07:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB