1

I am trying to get multiple inputs from a dropdown list but its returning a no value. herewith attached is the code: controller :-

public function mark_error($id = null, $email=null)
{
    if($this->userlib->isLoggedIn())
    {
        if($this->userlib->isAdmin())
        {
            $seller_error = $this->input->post('seller_error');
            if(is_null($seller_error))
            {
                $seller_error = array();
            }
            $marked_error_seller = implode(',', $seller_error);

            $bank_error = $this->input->post('bank_error');
            if(is_null($bank_error))
            {
                $bank_error = array();
            }
            $marked_error_bank = implode(',', $bank_error);

            $store_error = $this->input->post('store_error');
            if(is_null($store_error))
            {
                $store_error = array();
            }
            $marked_error_store = implode(',', $store_error);

            $id2 = $this->userlib->getId();
            $data['admin_data'] = $this->admin_panel_model->admin_data($id2);

            $data['marked_error_seller']=$marked_error_seller;
            $data['marked_error_store']=$marked_error_store;
            $data['marked_error_bank']=$marked_error_bank;
            $data['email']=$email;

            $this->admin_panel_model->mark_error_seller($id, $marked_error_seller);
            $this->admin_panel_model->mark_error_bank($id, $marked_error_bank);
            $this->admin_panel_model->mark_error_store($id, $marked_error_store);                               
            $this->load->view('send_mail', $data);
        }
        else
        {
            echo "User not Allowed";
        }
    }
    else
    {
        echo "User not Logged In";
    }
}

model:-

public function mark_error_seller($id, $marked_error_seller)
{
    $data = array('marked_error_seller'=>$marked_error_seller, 'seller_status'=>2);
    $this->db->update($this->seller_table, $data, array('id'=>$id));
    $status = array('error_status'=>1, 'admin_check'=>8);
    $this->db->update($this->table, $status, array('id'=>$id));
}

public function mark_error_bank($id, $marked_error_bank)
{
    $data1 = array('marked_error_bank'=>$marked_error_bank, 'bank_status'=>2);
    $this->db->update($this->bank_table, $data1, array('id'=>$id));
    $status = array('error_status'=>1, 'admin_check'=>8);
    $this->db->update($this->table, $status, array('id'=>$id)); 
}

public function mark_error_store($id, $marked_error_store)
{
    $data2 = array('marked_error_store'=>$marked_error_store, 'store_status'=>2);
    $this->db->update($this->store_table, $data2, array('id'=>$id));
    $status = array('error_status'=>1, 'admin_check'=>8);
    $this->db->update($this->table, $status, array('id'=>$id));
}

view:-

 <form action= "<?=site_url('admin_panel/mark_error/'.$id.'/'.$email)?>" method="post" enctype="multipart/form-data">
                          <div class="box-body">
                            <label>Seller Details</label>
                            <select name="seller_error[]" style = "width : 100%;" multiple="multiple" id="travel_lst" placeholder="">
                                    <option value="Business_Name">Business Name</option>
                                    <option value="Business+Address">Business Address</option>
                                    <option value="Mobile">Mobile</option>
                                    <option value="City">City</option>
                                    <option value="State">State</option>
                                    <option value="Pincode">Pincode</option>
                                    <option value="PAN">PAN</option>
                                    <option value="PAN_Proof">PAN Proof</option>
                                    <option value="TAN">TAN</option>
                                    <option value="TIN">TIN</option>
                                    <option value="TIN_Proof">TIN Proof</option>
                                    <option value="STRN">STRN</option>
                                    <option value="STRN_Proof">STRN Proof</option>
                                    <option value="Residence_Address">Residence Address</option>
                                </select>
                                <label>Bank Details</label>
                                <select name="bank_error[]" style = "width : 100%;" multiple="multiple" id="travel_lst" placeholder="">
                                    <option value="Beneficiary Name">Beneficiary Name</option>
                                    <option value="Bank Account Number">Bank Account Number</option>
                                    <option value="IFSC Code">IFSC Code</option>
                                    <option value="MICR Number">MICR Number</option>
                                    <option value="Bank Name">Bank Name</option>
                                    <option value="City">City</option>
                                    <option value="Branch">Branch</option>
                                    <option value="Cancelled Cheque">Cancelled Cheque</option>
                                    <option value="Address Proof">Address Proof</option>
                                    <option value="Type of Address Proof">Type of Address Proof</option>
                                    <option value="Identity Proof">Identity Proof</option>
                                    <option value="Type of Identity Proof">Type of Identity Proof</option>

                                </select>
                                <label>Store Details</label>
                                <select name="store_error[]" style = "width : 100%;" multiple="multiple" id="travel_lst" placeholder="">
                                    <option value="Billboard Image">Billboard Image</option>
                                    <option value="Company Display Name">Company Display Name</option>
                                    <option value="Company Description">Company Description</option>
                                    <option value="Company Logo">Company Logo</option>
                                    <option value="Travel Category">Travel Category</option>
                                    <option value="Travel Sub Category">Travel Sub Category</option>
                                    <option value="Travel Region">Travel Region</option>

                                </select>
                          </div>
                          <!-- /.box-body -->
                          <div class="box-footer">
                        <?php endforeach;?>
                            <input type="submit" class="btn btn-primary" value="Submit">
                          </div>
                        </form>

to elaborate,the status is successfully changed in the database but the inputs from the three dropdown list are not being updated,kindly help.

4
  • can you tell me what contain on this $this->table Commented Nov 3, 2015 at 9:18
  • $this->table is the table in the database with the name "seller" Commented Nov 3, 2015 at 9:28
  • can you give all table names?? So this $status = array('error_status'=>1, 'admin_check'=>8); and $data = array('marked_error_seller'=>$marked_error_seller, 'seller_status'=>2); this update into same table?? Commented Nov 3, 2015 at 9:29
  • no,they both are different tables Commented Nov 3, 2015 at 9:55

1 Answer 1

1

Try this

In Controller

public function mark_error($id = null, $email=null)
{
    if($this->userlib->isLoggedIn())
    {
        if($this->userlib->isAdmin())
        {

            $seller     = $this->input->post('seller_error');
            $bank   = $this->input->post('bank_error');
            $store  = $this->input->post('store_error');

            if (empty($seller) || empty($bank) || empty($store)) {
                echo "Field(s) is(are) Empty";
            }
            else
            {
                $id2 = $this->userlib->getId();
                if (empty($id2)) {
                    echo "ID Field is empty";
                }
                else
                {
                    $this->admin_panel_model->mark_error_seller($id, $seller);
                    $this->admin_panel_model->mark_error_bank($id, $bank);
                    $this->admin_panel_model->mark_error_store($id, $store);  

                    $data['admin_data'] = $this->admin_panel_model->admin_data($id2);  

                    $this->load->view('send_mail', $data);                  
                }
            }
        }
        else
        {
            echo "User not Allowed";
        }
    }
    else
    {
        echo "User not Logged In";
    }
}

In Model

public function mark_error_seller($id, $seller)
{
    $data = array(
       'marked_error_seller' => $seller,
       'seller_status' => '2',
       'error_status' => '1',
       'admin_check' => '8'
    );
    $this->db->where('id', $id);
    $this->db->update('seller', $data); # I assume tabe name is seller
}

public function mark_error_bank($id, $bank)
{
    $data = array(
       'marked_error_bank' => $bank,
       'bank_status' => '2',
       'error_status' => '1',
       'admin_check' => '8'
    );
    $this->db->where('id', $id);
    $this->db->update('bank', $data); # I assume tabe name is bank
}

public function mark_error_store($id, $store)
{
    $data = array(
       'marked_error_store' => $store,
       'store_status' => '2',
       'error_status' => '1',
       'admin_check' => '8'
    );
    $this->db->where('id', $id);
    $this->db->update('store', $data); # I assume tabe name is store
}
Sign up to request clarification or add additional context in comments.

4 Comments

its a multiple select dropdown list,so i will be getting an array by post method and will need to convert it into string,so the method you suggested needs this correction.
@AjitejKaushik did you check this??
sir,i am little busy with some other work related to my project,will test it tomorrow for sure
@AjitejKaushik Ok take you own time. Don't forget to accept + up vote it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.