Welcome Guest, Not a member yet? Register   Sign In
Can't apply WHERE condition in Mulitple checkbox
#1

[eluser]Unknown[/eluser]
Hello Masters,

I need help.I can't apply **WHERE** Condition clause in my Multiple selected checkbox value.like If i select 'accounitng' or 'php' then i want here use a condition like **WHERE** **("skill", "php")** here, skill table field name and php checkbox selected value.If i select a category 'PHP' so all 'PHP' related data only show.Checkbox selected value save into databse with ' , ' comma separated. like *`php,java,accounting,sql`*

For save data i used for Model:

Code:
public function saveInstituteOfferCourse($data = array()) {
            if ($this->db->insert('tbl_course_offred', $data)) {
                return $this->db->insert_id();
            }
            return FALSE;
        }

for controller i use:

Code:
public function saveCourses() {
            $data = array();
            $this->load->library('form_validation');
            $this->form_validation->set_rules('skill', 'skill', 'required');
            if ($this->form_validation->run()) {
                /* @var $skill user_admin_controller */
                $skill = implode(',', $this->input->post('skill'));
                $data['skill'] = $skill;
                $data['user_id'] = $this->session->userdata('user_id');
                $this->user_admin_model->saveInstituteOfferCourse($data);
                redirect("user_admin_controller/userAdminPanel");
            }
        }

My workflow likes:

First: user select many skills using multiple checkbox and save selected data into DB table.

Second: if anyone click on category on fronted page like php or java then only php or java related data information/list show.

How can i do this please help me or suggest me for best.if possible provide me source code in codeignitor.

My applying code have a look,

Model,

Code:
public function selectaccoutingins() {
            $this->db->select('*');
            $this->db->select('skill');
            $this->db->from('tbl_user_reg, tbl_course_offred');
            $this->db->where('skill', "php");
            // here, i use two table 1 for information collect and other for category match condition value show.
          
            $query_result = $this->db->get();
            $result = $query_result->result();
            $result = explode(",", $query_result->result);
            return $result;
            
        }

Controller,

Code:
function accounting_ins_list() {
            $data = array();
            $data['result'] = $this->welcome_model->selectaccoutingins();
            $data['catepage_list'] = $this->load->view('accounting_ins_list', $data, true);
            $this->load->view('hmcate_select_page', $data);
        }

view,

Code:
<tbody>
                        &lt;?php
                        
                        if($result) {
                        foreach ($result as $aresult) {
                        ?&gt;
                        <tr>
                            <td>&lt;?php echo $aresult->institute_name;?&gt;</td>
                            <td>&lt;?php echo $aresult->contact_person; ?&gt;</td>
                            <td>&lt;?php echo $aresult->institute_address1;?&gt;</td>
                        </tr>
                        &lt;?php }
                        
                        }   ?&gt;
                    </tbody>
here i want to show only **PHP related** information list.Please help how can i solve this.

Best regards,

#2

[eluser]rana[/eluser]
I didn't go through very deeply with your codes. But from your main concern, it seems like you should use
Code:
$this->db->where_in('skill',array("php","javascript"));

Please see if it works for you...




Theme © iAndrew 2016 - Forum software by © MyBB