SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2013
    0 Post(s)
    0 Thread(s)

    Error multiple checkbox insert value in CodeIngneter

    Happy New year

    please help me senior bro,I can't insert mulityple selected checkbox value into my databse.When i click SUBIT then it show me below error:

    *Error Number: 1054

    Unknown column '0' in 'field list'

    INSERT INTO `tbl_course_offred` (`0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `user_id`) VALUES ('1', '2', '3', '4', '89', '5', '22', '106', '133', '11')

    Filename: D:\xampp\htdocs\training\system\database\DB_driver.php

    Line Number: 330 *

    Here is my form page:

    *<form action="<?php echo base_url();?>user_admin_controller/saveCourses" method="post">

    <input type="checkbox" name="skill[]" id="skill[]" value="1" /> Accounting
    <input type="checkbox" name="skill[]" id="skill[]" value="2" /> Accounting Short term
    <input type="checkbox" name="skill[]" id="skill[]" value="3" /> Actuarial Courses
    <input type="checkbox" name="skill[]" id="skill[]" value="4" /> Advanced Accounting
    <input type="checkbox" name="skill[]" id="skill[]" value="89" /> Advanced Level
    <input type="checkbox" name="skill[]" id="skill[]" value="5" /> Air hostesses Training
    <input type="checkbox" name="skill[]" id="skill[]" value="97" /> AME
    <input type="checkbox" name="skill[]" id="skill[]" value="6" /> Athletic
    <input type="submit" name="submit" value="Submit" class="button"/>

    My CI_Controller:

    public function saveCourses() {
    $data = $_POST;
    if (isset($_POST['submit'])) {
    $data = $_POST['skill']; // here 'SKILL' = tabel Field name
    implode(',', $data);

    $data['user_id'] = $this->session->userdata('user_id');
    $this->user_admin_model->saveInstituteOfferdCourse($data); //model function_name: saveInstituteOfferdCourse

    My CI_MODEL:

    public function saveInstituteOfferdCourse($data) {
    // return $this->db->affected_rows();


    please help me how can i solve this problem?

    I have another help like:

    **Q. How can i display data without ',' comma view page ?**

    please please help me senior..


  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    France, deep rural.
    17 Post(s)
    1 Thread(s)
    I am not sure about your controller and model question, but dealing strictly with the error message.

    Unknown column '0' in 'field list'
    IF this is caused because you do not have a column in your table called "0", but in fact your first one is named "1":

    THEN you having to deal with the fact that the form is submitting a zero-based array, you can get round this by giving the very first array item (skill) a key of 1 like so:
    <input type="checkbox" name="skill[1]" id="skill[]" value="1" /> Accounting
    The rest can remain skill[].

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts