Responsive Advertisement

Select data in table & Update data of table

HTML about.php

<form method="post" action="<?php echo base_url(); ?>admin/about"  enctype='multipart/form-data'>
                <div class="tab-inn">
                  <div class="row">
                   <div class="col-lg-12 nopadding col s12">
                      <label style="margin-top: 20px;">About Description</label>
                      <textarea class="ckeditor" cols="80" id="descen1" rows="10" name="about_description"><?php if($about->field!=''){ echo $about->field; } ?></textarea>
                      <span class="error_val"><?php echo $this->session->flashdata('about_description'); ?></span>
                      <input type="hidden" name="id" value="<?php if($about->id!=''){ echo $about->id; } ?>" id="t3">
                    </div>
                  <div class="input-field col s12">
                    <i class="waves-effect waves-light btn-large waves-input-wrapper" style="">
                      <input type="submit" class="waves-button-input" value="Add"></i>
                  </div>
                  </div>
                  <div class="clearfix"></div>
                  </div>
                  <input type="text" name="edit" value="">
</form>


>>>>>>>>>>>>>>>>>>>>admin.php

public function about($input)
{
$input=$this->input->post();

$data['about']=$this->course_model->get_about();  (select data frome table)

if(!empty($input))
{
$result=$this->course_model->about($input);
    if($result==1)
      {
$this->session->set_flashdata('success','Data Submit.');
redirect('admin/about');
      }
      else
{
$this->session->set_flashdata('success','Fill the Data Not Changes.');
redirect('admin/about');

}

}
/*if condition is true then it work ((data submit & resubmit call submit))*/

$this->load->view('admin/about',$data);  (page loader)

}
................................................

admin.course.model.php
........................................................Model.................

public function get_about()
{
return $this->db->get('about')->row(); (Select from table only 1 row)
}

public function about($input)
{
$data=array('field'=>$input['about_description']);
if($input['id']=='')
{
$query=$this->db->insert('about',$data);
}
else
{
$query=$this->db->where('id',$input['id'])->update('about',$data);
}

if($query)
{
return true;
}
else
{
return false;
}


}


Table Name : About

ID: 1;
Field :  'hello fr. data inserted in row';

route



$route['admin/about'] = 'admin/admin/about';

$route i use for shortcut....


Note ::  <?php if($about->field!=''){ echo $about->field; } ?> in text area .html field.

$about is database name

(Field) is a table row name

Rule : if

<input type="hidden" name="id" value="<?php if($about->id!=''){ echo $about->id; } ?>" id="t3">

Post a Comment

0 Comments