Welcome Guest, Not a member yet? Register   Sign In
Multiple forms to one MySql table
#1

[eluser]Todlerone[/eluser]
Hello all and TY in advance. I have two forms that add to the same MySql table. In my model I have tried to parse the data depending on which form they came from. When I try it I get a:

A Database Error Occurred
You must use the "set" method to update an entry.

I'm trying to insert new data, not alter existing data.

Code:
<?php
   class Patients extends Model {
    function Patients(){
            parent::Model();
    }
    function add_schedule($ptID){
           $da =array();
        if ($this->input->post('sche_CDate') == TRUE){
            $da = array(
                'demo_NumID' => $ptID,
                'sche_date' =>$this->input->post('sche_CDate'),
                'sche_type' => 'con',
                'sche_location' => 'jcc');
        }
        if ($this->input->post('sche_RDate') == TRUE){
            $da = array(
                'demo_NumID' => $ptID,
                'sche_date' =>$this->input->post('sche_RDate'),
                'sche_type' => 'ref',
                'sche_location' => 'jcc');    
        }
        if ($this->input->post('fromform') == 'yes'){
            $da = array(
                'demo_NumID' => $ptID,
                'sche_date' => $this->input->post('sche_date'),
                'sche_type' => $this->input->post('sche_type'),
                'sche_location' => $this->input->post('sche_location'));
        }
        $this->db->insert('schedule', $da);
        }
}

TY
#2

[eluser]teampoop[/eluser]
This looks right to me. The only thing I can suggest is doing a echo $this->db->last_query() and see what the active record is trying to create.. HTH
#3

[eluser]Bart Mebane[/eluser]
It's possible you would get that message if none of the conditions are true and $da is empty.
#4

[eluser]Todlerone[/eluser]
TY teampoop. I tried adding a few echo's to pinpoint out my location. As it turns out. My last if statement comes from the form to add a scheduled appointment. The "fromform" field is a hidden element for me to check. It doesn't appear to enter this if/statement after the form submission. I haven't used hidden fields before.

Code:
if ($this->input->post('fromform') == 'yes'){




Theme © iAndrew 2016 - Forum software by © MyBB