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

[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

Code:
<?php
    
    
    function updateemployee()
    {
      // first load the Model
      $this->load->model->('skillsmodel');
      // then we can use a method..
      $this->skillsmodel->updateemployee();
      // everything ok redirect
      redirect('index.php/skils/employee');
     // header(“Location: http://localhost/aStage2CI/index.php/skills/employee”);
    }

?>
// model
<?php

  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
    $this->db->where($this->input->post('empid'));
  }

<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)
              {
        ?&gt;
        &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>

        Department:

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

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

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


Messages In This Thread
editing database - by El Forum - 04-16-2010, 09:37 PM
editing database - by El Forum - 04-17-2010, 12:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB