Iam developing using codeIgniter and I have managed to simply post a id number and phone number into the a table named "offers" both fields are INT, however when i try update a phone number corresponding to a specific id I keep getting the following error
Unknown column 'mysubmit' in 'field list'
UPDATE offers
SET phneNum
= '078444', mysubmit
= 'Submit Form' WHERE idNum
= '12'
Filename: C:\xampp\htdocs\project\system\database\DB_driver.php
I have listed my controller , model and view below
newOffer/controller
class newOffer extends CI_Controller {
function addOffer() {
//if the form is submitted
$this->load->view("check");
$this->load->model("offer_model");
if ($this->input->post('mysubmit')) {
$this->offer_model->entry_insert();
}
}
function updateOffer (){
$this->load->view("check");
$this->load->model("offer_model");
if ($this->input->post('mysubmit')) {
// $this->offer_model->upddata();
$this->offer_model->upddata($this->input->post());
}
}
}
?>
offer_model
class offer_model extends CI_Model{
public function entry_insert(){
$data = array(
'idNum' => $this->input->post('idNum'),
'phneNum' => $this->input->post('phneNum'),
);
$this->db->insert('offers',$data);
}
public function upddata($data) {
$data=array();
$idNum = $data['idNum'];
$data=$this->input->post(); //get all post value to data array
unset($data['idNum']); // unset unnecessary values
$this->db->where('idNum', $idNum)->update('offers' ,$data);
return true;
}
}
?>
The view // Please enter details for your new offer
<label for="ID Number">ID Number: <span class="required">*</span></label>
<input type="text" name="idNum" id="idNum" placeholder="Please enter ID Number/>
<label for="phone Number">Phone Number:</label>
<input type="text" name="phneNum" id="phneNum " placeholder="Please enter phone Number"/>
<fieldset class="submit_field">
<?php echo form_submit('mysubmit', 'Submit Form'); ?>
</fieldset>
</div><!-- end of form div -->
?>