Welcome Guest, Not a member yet? Register   Sign In
editing database

Lots of problems learning this, but is fun, especially when I get it to work Smile

Need to edit my database, but keeps looking for a file that isn't in existence, causing an error.

My code, maybe someone can see what I have done wrong (after 2 hours I can't!!) -

Controller -
function editemployee()
$data['title']="Edit An Employee";
$data['heading']="Employee Skills Database";
$data['pageheading']="Edit An Employee In The Database";

$this->db->where('empid', $this->uri->segment(3));
$this->load->view('editemployeeview', $data);

function updateemployee()
header("Location: http://localhost/aStage2CI/index.php/skills/employee");


Model -
function updateemployee($data)

$this->db->update('employee', $this, array('empid'=>$data['empid']));

View -
<div id = "content">
<h1 align="center">&lt;?=$pageheading?&gt;</h1>
<br />

<p>Employee First Name: <br />
&lt;input type="text" name="empfirstname"&gt;&lt;/p><br />
<p>Employee Last Name: <br />
&lt;input type="text" name="emplastname"&gt;&lt;/p><br />
<p>Department:<br />
&lt;input type="text" name="deptid"&gt;&lt;/p><br />
<p>&lt;input type="submit" name="submit" value="submit"&gt;&lt;/p>


[eluser]Bart v B[/eluser]
You mean you can't populate youre database views into youre form?
hmm.. see more things what i should do diffrent.. Wink

    function updateemployee()
      // first load the Model
      // then we can use a method..
      // everything ok redirect
     // header(“Location: http://localhost/aStage2CI/index.php/skills/employee”);

// model

  function updateemployee()
    // first create a data array()
    $data = array(
                  'empfirstname' => $this->input->post('empfirstname'),
                  'emplastname'  => $this->input->post('emplastname')
    // do the update on the table, with the data array()
    $this->db->update('employee', $data);
    // where he must update

<div id = “content”>
      <h1 align=“center”>&lt;?php echo $pageheading; ?&gt;</h1>

      &lt;?php echo form_open('employee/updateemployee');?&gt;
      &lt;?php echo form_hidden('empid',$this->uri->segment(3));?&gt;

        Employee First Name:
        &lt;?php foreach($query as $row)
        &lt;input type="text" name="empfirstname" value="&lt;?php echo $row-&gt;empfirstname;?&gt;" /></p>

        Employee Last Name:

        &lt;input type="text" name="emplastname" value="&lt;?php echo $row-&gt;emplastname;?&gt;" /></p>


        &lt;input type="text" name="deptid" value="&lt;?php echo $row-&gt;emtid;?&gt;" /></p>

        &lt;input type=“submit” name=“submit” value=“submit”&gt;&lt;/p>

Whoops i made a little mistake i think, but it should be something like this.

Theme © iAndrew 2016 - Forum software by © MyBB