insert data into database with codeigniter
Try this in your model:
function order_summary_insert()
$OrderLines=$this->input->post('orderlines');
$CustomerName=$this->input->post('customer');
$data = array(
'OrderLines'=>$OrderLines,
'CustomerName'=>$CustomerName
);
$this->db->insert('Customer_Orders',$data);
}
Try to use controller just to control the view and models always post your values in model. it makes easy to understand.
Your controller will be:
function new_blank_order_summary() {
$this->sales_model->order_summary_insert($data);
$this->load->view('sales/new_blank_order_summary');
}
Inserting data into Database CodeIgniter 3.x
I got it to finally work using:
$sql = sprintf("INSERT INTO users (created_at, updated_at, first_name, last_name, email, auth_key, enabled, deleted) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', %d, %d)", $data['created_at'], $data['updated_at'], $data['first_name'], $data['last_name'], $data['email'], $data['auth_key'], $data['enabled'], $data['deleted']);
$this->db->query($sql);
Related Topics
Url Encoded Forward Slashes Breaking My Codeigniter App
Pdo's Rowcount() Not Working on PHP 5.2.6+
Including PHP Variables in an External Js File
Setting $_Session Doesn't Work on Localhost Using Xampp
How to Check If the Request Came from Mobile or Computer in PHP
Can Mongodb and Its Drivers Preserve the Ordering of Document Elements
How to Subtract 24 Hour from Date Time Object in PHP
File Upload PHP $_Files Undefined Index Error
Using PHP, How to Insert Text Without Overwriting to the Beginning of a Text File
How to Validate Non-English (Utf-8) Encoded Email Address in JavaScript and PHP
PHP Xpath - Find Element with a Value and Also Get Elements Before and After Element
How to Change the Name of an Element in Dom
Why Is My Database Backup Script Not Working in PHP
What Does the "&" Sign Mean in PHP
Facebook Oauthexception: "User Hasn't Authorized the Application to Perform This Action"