user3840485
user3840485

Reputation: 5065

codeigniter insert date into database which is sent fom post method

in my date input field in the form I get date using date picker. Now I need to know how can I save that particular date in the database table,I don't know how to access date at the model.

this is form field

Date: <input type="text" id="datepicker"/>

this is model

function save_cheque(){

    $insert_cheque_data = array(

        'name' => $this->input->post('name'),
        'amount' => $this->input->post('amount'),
        'amount_letters' => $this->input->post('amount_in_words'),
        'address' => $this->input->post('address'),
        'account_no' => $this->input->post('acc_no'),
        'bank' => $this->input->post('bank'),
        'date' => $this->input->post('date'),
             ); 

        $this->db->insert('cheque_details',$insert_cheque_data);

        $this->load->database();
        $query = $this->db->query("SELECT MAX(id) AS id FROM companydetails");
        return $query->result();        

}

Upvotes: 0

Views: 4848

Answers (1)

John Conde
John Conde

Reputation: 219804

You just need to give that form field a name just like any other form field. The datepicker will populate it with a value for you.

<input type="text" name="date" id="datepicker"/>

You access it in your PHP normally:

'date' => $this->input->post('date'),

Upvotes: 1

Related Questions