Profile_view.php
---------------
<?php echo form_open('profile/update_data')?>"
Firstname:
<input name="firstname" value="<?php echo $firstname;?>">
Lastname:
<input name="lastname" value="<?php echo $lastname;?>">
Dob:
<input type="date" name="dob" value="<?php echo $dob;?>"></p>
Profileimage:
<input type="text" name="profileImage" value="<?php echo $profileImage;?>">
<input type="submit" name="submit" value="Submit">
<?php echo form_close()?>
Profile_model
-----------------
<?php
class Profile_model extends CI_Model{
function show(){
$id=120;
$query=$this->db->query("SELECT * FROM profile WHERE id='$id'");
if($query->num_rows()>0){
return $query->result();
}else{
return FALSE;
}
}
function update_data($data){
$id=120;
$this->db->where('id', $id);
if($this->db->update('profile', $data)){
return TRUE;
}
}
}
Profile_Controller.php
-------------
<?php
class Profile extends CI_Controller{
function __construct(){
parent::__construct();
}
function display(){
$this->load->view('profile_view');
}
function data_display(){
$this->load->model('profile_model');
$profile=$this->profile_model->show();
if($profile){
$data=array(
'firstname'=>$profile[0]->firstName,
'lastname'=>$profile[0]->lastName,
'dob'=>$profile[0]->dob,
'profileImage'=>$profile[0]->profileImage
);
$this->load->view('profile_view',$data);
}else{
$data['profile_err']="No data to display";
$this->load->view('profile_view',$data);
}
}
function update_data() {
$data = array(
'firstname' => $this->input->post('firstname'),
'lastname' => $this->input->post('lastname'),
'dob' => $this->input->post('dob'),
'profileImage' => $this->input->post('profileImage')
);
$this->load->model('profile_model');
if($this->profile_model->update_data($data))
$this->data_display();
}
}
?>
---------------
<?php echo form_open('profile/update_data')?>"
Firstname:
<input name="firstname" value="<?php echo $firstname;?>">
Lastname:
<input name="lastname" value="<?php echo $lastname;?>">
Dob:
<input type="date" name="dob" value="<?php echo $dob;?>"></p>
Profileimage:
<input type="text" name="profileImage" value="<?php echo $profileImage;?>">
<input type="submit" name="submit" value="Submit">
<?php echo form_close()?>
Profile_model
-----------------
<?php
class Profile_model extends CI_Model{
function show(){
$id=120;
$query=$this->db->query("SELECT * FROM profile WHERE id='$id'");
if($query->num_rows()>0){
return $query->result();
}else{
return FALSE;
}
}
function update_data($data){
$id=120;
$this->db->where('id', $id);
if($this->db->update('profile', $data)){
return TRUE;
}
}
}
Profile_Controller.php
-------------
<?php
class Profile extends CI_Controller{
function __construct(){
parent::__construct();
}
function display(){
$this->load->view('profile_view');
}
function data_display(){
$this->load->model('profile_model');
$profile=$this->profile_model->show();
if($profile){
$data=array(
'firstname'=>$profile[0]->firstName,
'lastname'=>$profile[0]->lastName,
'dob'=>$profile[0]->dob,
'profileImage'=>$profile[0]->profileImage
);
$this->load->view('profile_view',$data);
}else{
$data['profile_err']="No data to display";
$this->load->view('profile_view',$data);
}
}
function update_data() {
$data = array(
'firstname' => $this->input->post('firstname'),
'lastname' => $this->input->post('lastname'),
'dob' => $this->input->post('dob'),
'profileImage' => $this->input->post('profileImage')
);
$this->load->model('profile_model');
if($this->profile_model->update_data($data))
$this->data_display();
}
}
?>
0 comments:
Post a Comment