Ok..Now I am going to do the next part of the cURD.That is update the data.
Well...Let us start.
I need a model controller and a view.First I will create my controller...
Here is my controller.Save it in C:\xampp\htdocs\CodeIgniter\application\controllers dirctory as updatecontroller.php
<?php
class updatecontroller extends CI_Controller{
public class view(){
$this->load->view('updateview');
}
public class edit(){
$name=$this->input->post('name');
$id=$this->input->post('id');
$this->load->model('updatemodel');
$this->updatemodel->update($name,$id);
}
}
?>
Now I need the model file.Open a new file and save it as updatemodel.php in C:\xampp\htdocs\CodeIgniter\application\models directory.
here is the codes..
<?php
class updatemodel extends CI_Model{
public function update($name,$id){
$this->db->query("update info set Name='$name' where ID='$id'");
$this->load->view('updateview');
}
}
?>
Now I need a view.Open a new file and save it is updateview.php in C:\xampp\htdocs\CodeIgniter\application\views directory..
here is my view file
<?php echo form_open("updatecontroller/edit"); ?>
Enter the id :<input name="id"/>
Enter the new name :<input name="name"/>
<input />
<?php echo form_close(); ?>
Now it is ok..
Go to the web browser and type below in address bar..
http://localhost/codeigniter/index.php/updatecontroller/edit
****and you will see the below output.
Well...Let us start.
I need a model controller and a view.First I will create my controller...
Here is my controller.Save it in C:\xampp\htdocs\CodeIgniter\application\controllers dirctory as updatecontroller.php
<?php
class updatecontroller extends CI_Controller{
public class view(){
$this->load->view('updateview');
}
public class edit(){
$name=$this->input->post('name');
$id=$this->input->post('id');
$this->load->model('updatemodel');
$this->updatemodel->update($name,$id);
}
}
?>
Now I need the model file.Open a new file and save it as updatemodel.php in C:\xampp\htdocs\CodeIgniter\application\models directory.
here is the codes..
<?php
class updatemodel extends CI_Model{
public function update($name,$id){
$this->db->query("update info set Name='$name' where ID='$id'");
$this->load->view('updateview');
}
}
?>
Now I need a view.Open a new file and save it is updateview.php in C:\xampp\htdocs\CodeIgniter\application\views directory..
here is my view file
<?php echo form_open("updatecontroller/edit"); ?>
Enter the id :<input name="id"/>
Enter the new name :<input name="name"/>
<input />
<?php echo form_close(); ?>
Now it is ok..
Go to the web browser and type below in address bar..
http://localhost/codeigniter/index.php/updatecontroller/edit
****and you will see the below output.